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
Santiago Pastorino
2b22acff53
Use the readers instead of accessing the ivar directly
2013-05-21 17:03:07 -07:00
Santiago Pastorino
1a8709d71c
Move caching to a new module
2013-05-21 17:03:06 -07:00
Santiago Pastorino
0e876624ec
Move reusable code to a module
2013-05-21 17:03:05 -07:00
Santiago Pastorino
64ed05c484
Define serializer as DefaultSerializer if not set
2013-05-21 17:03:05 -07:00
Jason Kriss
4e762ee8b5
fix a couple typos
2013-04-18 13:39:14 -07:00
Prathamesh Sonpatki
7d1ce9c56e
Fixed typos
2013-03-26 18:18:20 +05:30
Kevin Mahoney
2bd447d69d
Pass options through when using default serializer
2013-03-22 13:12:33 +00:00
twinturbo
c3966fe741
ArraySerializer is also cached
2013-03-14 22:54:05 +01:00
Adam Stanton
5a55a6831a
Remove line break on the conditional statement.
2013-03-06 11:48:50 -08:00
Adam Stanton
da26ebd26f
Merge branch 'create-default-serializer' into HEAD
...
Conflicts:
lib/active_model/array_serializer.rb
2013-03-05 21:48:58 -08:00
Nicholas Mulder
fa51c5f574
Add ActiveSupport::DescendantsTracker to Serializer and ArraySerializer
2013-02-28 10:01:40 -05:00
Tony Pitale
dcd4121322
reduce 2x map; fixes datamapper eager loading
2013-02-17 16:44:27 -05:00
Adam Stanton
c4fcf96eb4
Move DefaultSerializer from array_serializer.rb to serializer.rb
2013-02-10 09:49:11 -08:00
Adam Stanton
8f6218c587
Create DefaultSerializer so that as_json uses same interface.
...
This is to ensure that PORO's as_json is called if no serializer
is specified.
Original behaviour was that serializable_hash was being called,
overriding the as_json method.
2013-02-10 09:06:24 -08:00
tchak
a71698d5bb
Add support for meta key
...
Test for meta_key serialization
2012-11-22 13:44:59 +01:00
Tee Parham
b8f01ba2f3
move ArraySerializer to separate file
2012-09-18 01:28:07 +02:00