Commit Graph

329 Commits

Author SHA1 Message Date
Santiago Pastorino
66f9256534 Embed objects should return singular and not wrap in array
Closes #437
2013-11-01 14:22:52 -02:00
Santiago Pastorino
d3d6c98148 Make ArraySerializer reuse Serializer embedded_in_root_associations code 2013-10-31 17:28:39 -02:00
Santiago Pastorino
5598bb0f79 Make Associations in root work with ArraySerializer
Closes #414
2013-10-31 17:27:36 -02:00
Santiago Pastorino
85a9c185ca Move responsibility of setting a serializer class and building a serializer for an association to the association class 2013-10-31 16:45:00 -02:00
Santiago Pastorino
616938dc63 Improve build_json_serializer readability a bit 2013-10-30 23:37:36 -02:00
Santiago Pastorino
4d4b820cbe has_one returns arrays with roots pluralized 2013-10-30 15:26:13 -02:00
Santiago Pastorino
1eea008336 Split root construction and serialization logic 2013-10-29 19:39:27 -02:00
Santiago Pastorino
49ab359a34 Support passing a custom ArraySerializer for has_many associations
Thanks @phoet

Closes #316
2013-10-29 00:26:45 -02:00
Santiago Pastorino
d5308b4d0b Remove old unneeded code 2013-10-26 03:01:17 -02:00
Santiago Pastorino
1eb09476ef Revert "Merge pull request #422 from marclove/reduce-serializer-code-complexity"
This reverts commit 449849516b, reversing
changes made to e103569c22.

Conflicts:
	lib/active_model/serializer.rb
2013-10-26 01:19:15 -02:00
Arthur Neves
303ac21428 Small refactoring 2013-10-25 19:58:06 -04:00
Marc Love
5ac6e626b5 Reduce complexity and duplication; make accessor definition more explicit 2013-10-25 15:33:24 -07:00
Santiago Pastorino
439643ba5a Fix the stupid previous commit 2013-10-24 19:23:50 -02:00
Santiago Pastorino
b44e1af5dd Move synchronize to setup method and make CONFIG private 2013-10-24 17:42:20 -02:00
Santiago Pastorino
dc33dac56b This is not being used 2013-10-24 16:57:42 -02:00
Santiago Pastorino
dfdc292e35 Align = 2013-10-24 16:32:18 -02:00
Arthur Neves
860acad9af s/side_load/embed_in_root 2013-10-24 14:12:02 -04:00
Santiago Pastorino
2b70503896 Add ActiveModel::SerializerSupport 2013-10-24 16:09:00 -02:00
Santiago Pastorino
cef6f85f44 Deprecate include in favor of side_load 2013-10-24 15:09:26 -02:00
Santiago Pastorino
48db253765 embed_in_root is now side_load 2013-10-24 14:57:41 -02:00
Santiago Pastorino
5c6541145a Allow to embed nothing but still side loading
Closes #361, #399, #401
2013-10-24 13:24:49 -02:00
Santiago Pastorino
df5ef33ae6 Allow to turn off ams
Closes #378

You can define now

```
def default_serializer_options
  { serializer: false }
end
```
2013-10-23 20:34:34 -02:00
Łukasz Strzałkowski
d46584af40 Wrap config's data hash in mutex 2013-10-21 20:27:01 +00:00
Arthur Neves
05ec509e1c Use ActiveSupport::Deprecation.warn instead of warn 2013-10-21 15:02:39 -04:00
Santiago Pastorino
7dcef9f0f5 Rename Settings to Config and use accessors to configure things 2013-10-21 16:23:35 -02:00
Arthur Neves
84801301b9 Add deprecation message to .embed method 2013-10-21 13:08:07 -04:00
Arthur Neves
41f1855056 Add accessors to settings class 2013-10-21 13:05:39 -04:00
Santiago Pastorino
4ab16381bd Bump version to 0.9.0.pre 2013-10-18 17:49:22 -02:00
Santiago Pastorino
73774649e3 Implement Generators 2013-10-18 17:49:21 -02:00
Santiago Pastorino
91f9317713 There's no need to define read_attribute_for_serialization in the Serializer class 2013-10-18 17:49:21 -02:00
Santiago Pastorino
b9a6dfac2f Do not call send on associated objects, do it through elem.read_attribute_for_serialization 2013-10-18 17:49:21 -02:00
Santiago Pastorino
4b91d0e5ec embed :objects is the default
A commit with an integration test that covers this functionality is
coming after this one
2013-10-18 17:49:20 -02:00
Santiago Pastorino
4f70dc2091 has_one serialized objects shouldn't be wrapped in an array and it's key is singular 2013-10-18 17:49:20 -02:00
Santiago Pastorino
dbf512c14c Make embed nil ids work 2013-10-18 17:49:20 -02:00
Santiago Pastorino
cad8fafa60 Optimize serializer_for for Ruby >= 2.0 2013-10-18 17:49:20 -02:00
Santiago Pastorino
841f3b8181 Add filter to allow users implement filter method to include/exclude attributes and relations 2013-10-18 17:49:20 -02:00
Santiago Pastorino
f6ea07dd22 Do not convert attrs to String until needed 2013-10-18 17:49:20 -02:00
Santiago Pastorino
daa9304398 Do not convert root and meta_key to Strings 2013-10-18 17:49:20 -02:00
Santiago Pastorino
75e9a2599d Store attributes as they are instead of converting them into Strings 2013-10-18 17:49:20 -02:00
Santiago Pastorino
10e882a14f Allow to set embed options from AM::Serializer 2013-10-18 17:49:20 -02:00
Santiago Pastorino
aa23e811cc Use controller name as root when serializing an array and not root is defined 2013-10-18 17:49:20 -02:00
Santiago Pastorino
86b9d5a226 Avoid work inside serializable_array 2013-10-18 17:49:20 -02:00
Santiago Pastorino
8006529e20 Allow ArraySerializer to pass the options down to item serializers 2013-10-18 17:49:19 -02:00
Santiago Pastorino
6f3503c965 Use serializer name as root when root not set 2013-10-18 17:49:19 -02:00
Santiago Pastorino
626a85bc3e Allow using root = false in initialize 2013-10-18 17:49:19 -02:00
Santiago Pastorino
8462a73f3a Make render json work when not using AMS 2013-10-18 17:49:19 -02:00
Santiago Pastorino
7405baafd7 Serialize associations that doesn't have an associated serializer 2013-10-18 17:49:19 -02:00
Santiago Pastorino
513e7f2166 Add setup method and Setting object to configure AMS 2013-10-18 17:49:19 -02:00
Santiago Pastorino
29148cbe1c Add AC::Serialization#serialization_scope as a class level method 2013-10-18 17:49:19 -02:00
Santiago Pastorino
0e0341effc Implement embed in root 2013-10-18 17:49:19 -02:00