Commit Graph

66 Commits

Author SHA1 Message Date
Yosi Attias
af410c54e6 Removing instrumentation_keys in order to fix the payload
See - https://github.com/rails-api/active_model_serializers/issues/2067
2017-03-24 14:59:35 +03:00
Josh Lane
0e7cae4d6d pass context to ArraySerializer 2015-01-27 11:37:35 -08:00
Robin Daugherty
f385ab05fb Make options param optional 2014-10-12 12:01:01 -04:00
Robin Daugherty
57f1c1b1f9 Fix serialization_options for array serialization 2014-10-12 02:29:50 -04:00
Steve Klabnik
c19a254154 Merge pull request #632 from gauthier-delacroix/Default_namespace_inheritance
Default namespace option
2014-09-25 19:41:33 -04:00
Gauthier Delacroix
a862929f81 Fix embed_in_root_key merging 2014-09-09 11:27:08 +02:00
Gauthier Delacroix
8514528db7 Allow default namespace inheritance 2014-09-03 12:41:30 +02:00
Theodore Konukhov
493041fdff sync with upstream 2014-08-29 06:28:13 +02:00
Theodore Konukhov
dde1492934 tests for namespaced controlleler 2014-08-26 18:07:31 +02:00
Pol Miro
26d5fb7423 Add support to polymorphic models 2014-08-25 23:32:09 -07:00
Theodore Konukhov
26c0847563 - If a controller is in a namespace, serializer will be looked up in this namespace first.
- Serializers for associations will be looked up in a parent serializer's namespace first too.
- "Prefix" option for different versions of associations serializers. Example: has_many :users, as: :short -> ShortUserSerializer

TODO: tests, config option for enabling namespace lookup
2014-08-24 15:57:24 +02:00
Steve Klabnik
e9378cc9ab Merge pull request #595 from bolshakov/feature/array_serializer_options
Array serializer pass except and only options to item serializers
2014-08-22 15:26:17 -04:00
Steve Klabnik
92f1db0137 Merge pull request #596 from bolshakov/feature/instumentation
Test::Unit assert_serializer implemented
2014-08-22 15:25:52 -04:00
Tema Bolshakov and Dmitry Myaskovskiy
eaedcefa4e Test::Unit assert_serializer implemented
So you can assert specific serializer to be used.
2014-08-18 18:04:51 +04:00
Tema Bolshakov
e3ab34dd74 Array serializer pass except and only options to item serializers 2014-08-18 14:21:08 +04:00
Vladimir Lyzo
adcea6aaf0 Fix failing test: option format_key with root option 2014-08-15 16:21:40 +04:00
Paul Henry
76263865a7 fix uninitialized instance variable warning
Ruby warns that `@only` and `@except` are not initialized because if they are not passed in, they are never assigned.

Remove circular require in array_serializer
2014-08-02 14:05:37 -07:00
Kyle Fritz
76c8de7b9f root key format 2014-04-14 13:45:12 -04:00
Kyle Fritz
00c54baae3 Support lowerCamel key format 2014-03-30 12:31:21 -04:00
Adrian Mugnolo and Santiago Pastorino
cec7980208 Don't embed empty associations in root 2014-01-09 15:45:20 -02:00
Santiago Pastorino
3e510c829b Don't concat to nil objects 2014-01-09 15:35:29 -02:00
Santiago Pastorino
ed9a5288f9 Revert "Merge branch 'context'"
This reverts commit 1bd8180a94, reversing
changes made to 9bb32331f4.
2014-01-07 15:02:09 -02:00
Adrian Mugnolo and Santiago Pastorino
0d8ef2b165 Nest scope under context option 2014-01-06 15:50:30 -02:00
Santiago Pastorino
8bd2542ed2 Allow to pass context around serializers 2014-01-06 12:22:16 -02:00
Santiago Pastorino
5fa4002039 Allow only to pass scope to associations
Closes #483
2014-01-03 19:48:01 -02:00
Adrian Mugnolo and Santiago Pastorino
0f4547eb77 Rename method to serializable_object 2013-12-17 16:13:50 -02:00
Adrian Mugnolo and Santiago Pastorino
28fbb62ec4 Avoid unneeded logic 2013-12-17 13:14:39 -02:00
Santiago Pastorino
5c00ce0443 Merge pull request #451 from plexus/embed_in_root_merge
embed_in_root only returns the associated objects of a single instance
2013-12-16 10:39:53 -08:00
Jason Truluck
a110df6caf Add @options back into serializers to maintain the functionality of render :json as noted in the docs
This functionality used to exist in v0.8.1. This adds the ability to
pass other options that will be usable in the serializer via the
options accessor.

This works by adding an attr_accessor for options so it is available
and is set by the remaining options in the provided options hash during
initialization.
2013-11-12 12:57:31 -05:00
Arne Brasseur
1db96ec7a9 When using embed: :ids ; embed_in_root: true, and serializing multiple objects,
only the associated objects of the last object in the collection will actually
show up in the serialized data.

For example, if you serialize a collection of two posts, each containing one or
more comments, only the comments of the last post show up. The reason is a
Hash#merge wich overwrites the array rather than appending to it.

This commit fixes this by merging the collection arrays, rather than the top-level
hashes.
2013-11-11 14:30:34 +01:00
Santiago Pastorino
882dbafa7e embedded_in_root_associations is always defined 2013-11-01 21:37:49 -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
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
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
626a85bc3e Allow using root = false in initialize 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
3fcd8c5f98 Define root and root= as aliases of _root= 2013-10-18 17:49:18 -02:00
Santiago Pastorino
7ba05c02e3 Make Serializable module which implements as_json 2013-10-18 17:49:18 -02:00
Santiago Pastorino
e6993c677b Add missing requires 2013-10-18 17:49:18 -02:00
Santiago Pastorino
a820e9774f Add ArraySerializer's root and meta features 2013-10-18 17:49:18 -02:00
Santiago Pastorino
f647b7ae74 Implement each_serializer 2013-10-18 17:49:18 -02:00
Santiago Pastorino
7e83f0c29d Implement ArraySerializer 2013-10-18 17:49:18 -02:00
Santiago Pastorino
14f51f2ea9 Remove everything, rewrite of AMS starts here 2013-10-18 17:46:18 -02:00
Tee Parham
74ba9dc76c upgrade hash syntax 2013-05-30 15:25:06 -06:00
Santiago Pastorino
c97acfd9ba Always set a serializer for each item of an Array
model.active_model_serializer could return nil so we need to ensure that
if serializer is not setted we set DefaultSerializer to it.

This reverts commit 64ed05c484.

Fixes #318
2013-05-28 18:13:07 -07:00
Thomas Scholtes
258248d6c0 Don't wrap array items in root element 2013-05-24 10:23:59 +02:00