Santiago Pastorino
d2f2508825
Reuse ivar
2013-10-24 13:40:24 -02:00
Santiago Pastorino
04f8c0c16f
Those are config tests
2013-10-24 13:37:15 -02:00
Santiago Pastorino
c83e643edd
Those lines are not needed
2013-10-24 13:35:57 -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
Santiago Pastorino
06e4c2c9d6
Test attributes declared as strings
...
Thanks @mikegee
Closes #380
2013-10-22 11:55:32 -02:00
Arthur Neves
55baaf2005
Dont use Class.embed on test
2013-10-21 15:10:00 -04:00
Arthur Neves
2ea0920f08
s/assert/assert_equal
2013-10-21 14:27:18 -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
41f1855056
Add accessors to settings class
2013-10-21 13:05:39 -04:00
Arthur Neves
f6d5340f89
Require minitest instead of test/unit
2013-10-18 17:49:22 -02:00
Arthur Neves
cf8b55ea01
Setting join_table on AR tests
2013-10-18 17:49:22 -02:00
Santiago Pastorino
b81deac320
Add coverage tools
2013-10-18 17:49:21 -02:00
Santiago Pastorino
73774649e3
Implement Generators
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
94a83c1cc0
Make relationship graph of AR integration tests bigger
2013-10-18 17:49:21 -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
23e6ed32be
Add default_serializer_options test
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
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
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
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
Santiago Pastorino
af34adc7b5
Move key's initialization code to initializers
2013-10-18 17:49:19 -02:00
Santiago Pastorino
280fd65db8
Allow to set key for associations through options
2013-10-18 17:49:19 -02:00
Santiago Pastorino
48590a2e37
Allow to set root for associations through options
2013-10-18 17:49:19 -02:00
Santiago Pastorino
8a495b1d00
Embedded has_one returns an array with the key pluralized
2013-10-18 17:49:19 -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
70ea6c6bc7
Add has_one and has_many :serialize => tests
2013-10-18 17:49:18 -02:00
Santiago Pastorino
cd3e5e9de2
Assign the association in the setup method
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
61a1669a86
Implement has_many
2013-10-18 17:49:18 -02:00
Santiago Pastorino
fa61314d0e
Add AR integration tests
2013-10-18 17:49:18 -02:00
Santiago Pastorino
4c7599cfff
Use more meaningful model names for tests
2013-10-18 17:49:18 -02:00
Santiago Pastorino
516f5bdceb
Implement has_one's embed ids include true
2013-10-18 17:49:18 -02:00
Santiago Pastorino
52bb3f6929
Implement has_one's embed objects
2013-10-18 17:49:17 -02:00
Santiago Pastorino
d756ae4a70
Implement has_one's and serialize_ids
2013-10-18 17:49:17 -02:00
Santiago Pastorino
01bc534976
Remove SerializerSupport
2013-10-18 17:49:17 -02:00
Santiago Pastorino
0d4dfb69a9
Fix directories the project is on top level dir
2013-10-18 17:49:17 -02:00
Santiago Pastorino
0c91564101
Remove method redefined warning
2013-10-18 17:49:17 -02:00
Santiago Pastorino
93baaa96b1
Implement meta and meta_key for AM::Serializer
2013-10-18 17:49:17 -02:00
Santiago Pastorino
af357619c1
Add AMS support to AR objects
2013-10-18 17:49:17 -02:00
Santiago Pastorino
a25c352525
Move models and serializers in test to fixtures.rb file
2013-10-18 17:49:17 -02:00
Santiago Pastorino
0d3b56e9cf
Implement AC integration
2013-10-18 17:49:17 -02:00
Santiago Pastorino
d41e5ccef7
Implement SerializerSupport class
2013-10-18 17:49:17 -02:00
Santiago Pastorino
45453f638b
Tests refactor
2013-10-18 17:49:17 -02:00
Santiago Pastorino
b6f9c5ee43
Implement Serializer's scope
2013-10-18 17:49:16 -02:00
Santiago Pastorino
c3f857d1b6
Implement Serializer's root
2013-10-18 17:49:16 -02:00
Santiago Pastorino
7143eb8301
Serialize just attributes
2013-10-18 17:49:16 -02:00
Santiago Pastorino
14f51f2ea9
Remove everything, rewrite of AMS starts here
2013-10-18 17:46:18 -02:00
Damian Galarza
0d674369ff
Use minitest/autorun
...
Allows edge gemset to build
2013-06-04 19:17:31 -04:00
Tee Parham
c3fa96456c
upgrade hash syntax in tests
2013-05-30 15:25:06 -06:00
Tee Parham
143e5d9866
do not generate id method (was for 1.8 only)
...
see https://github.com/rails-api/active_model_serializers/issues/127
for original motivation
2013-05-29 19:39:00 -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
Santiago Pastorino
f68003f64d
Merge pull request #313 from geigerzaehler/fix_root
...
Don't wrap array items in root element
2013-05-24 14:49:41 -07:00
Santiago Pastorino
9521e912fe
serialize_ids call methods on the corresponding serializer if defined
2013-05-24 14:09:27 -07:00
Thomas Scholtes
258248d6c0
Don't wrap array items in root element
2013-05-24 10:23:59 +02:00
Damian Galarza
bbc3ae44cc
Allow a controller to properly override scope_name
2013-05-21 21:24:50 -04:00
Santiago Pastorino
1a8709d71c
Move caching to a new module
2013-05-21 17:03:06 -07:00
Steve Klabnik
48e5ca29f1
Add Coveralls for code coverage.
2013-05-05 13:38:56 -07:00
Steve Klabnik
bb8900e308
Merge pull request #264 from vad4msiu/features/root_element
...
Support for setting root element
2013-05-05 12:02:27 -07:00
Steve Klabnik
cffdbce072
Merge pull request #283 from morgoth/add-only-and-except-options-support
...
Add only and except options support
2013-05-05 12:00:59 -07:00
Gosha Arinich
1482081766
add support of mongoid collection serialization
2013-05-05 21:50:34 +03:00
Wojciech Wnętrzak
489ebf2132
Added support for :only and :except methods.
...
It is possible now to filter returned attributes and associations by:
UserSerializer.new(user, only: [:first_name, :last_name])
UserSerializer.new(user, except: :first_name)
2013-04-27 21:29:26 +02:00
vanstee
ef6ab5f0c0
Switch back to the old hash syntax
...
Just fixed up a couple of hash literals in the tests so that the build
passes for 1.8.7
2013-04-16 22:55:57 -04:00
Steve Klabnik
c1dacccbdc
Merge pull request #273 from seanabrahams/embed-ids-not-using-local-method
...
Fixes #267
2013-04-15 17:44:06 -07:00
Sean Abrahams
79acd87829
Use method instead of asssociation_ids if method exists. Fixes #267
2013-04-10 14:38:53 -07:00
Sean Abrahams
a771f30816
If output is as expected, is this assert important?
2013-04-10 14:36:42 -07:00
vanstee
a900d31041
Support strings as attribute names
...
When generating the `_fast_attributes` method, attribute names that
could not be represented as symbols (at least without escaping) would
throw parsing errors.
2013-04-09 00:53:56 -04:00
vad4msiu
95081410d2
Support for setting root element
2013-04-04 15:10:29 +04:00
Steve Klabnik
ab5d40f38b
Sigh.
...
When I did 9551a97464 , I
forgot that some new code may use it.
2013-04-03 23:56:06 -07:00
Steve Klabnik
9551a97464
Revert 37b0690fb8.
...
This feature causes more problems than it solves.
2013-04-03 17:24:08 -07:00
Prathamesh Sonpatki
f6cf469820
Fix failing tests for edge rails
...
* Edge Rails returns an instance of 'Gem::Version' for 'Rails.version' due to e600384515dc06db2c56ff5be5c18779f7b379a5
* Travis build was failing because of this as 'Rails.version.start_with? '4'' was giving 'undefined method' on 'Gem::Version' instance
2013-03-27 10:29:36 +05:30
Prathamesh Sonpatki
75a72b5cc9
Fixed few typos
2013-03-26 20:29:35 +05:30
Steve Klabnik
c129ae2016
Generate id method on Ruby 1.8.
...
Because object_id and id went through some flux, it's best to tell 1.8
specifically what we mean.
Closes #127 .
2013-03-19 14:53:08 -07:00
beerlington
4a13f86961
Reference scope by same name as serialization scope
...
By default, the serialization scope uses current_user, and you can
now reference the scope as "current_user" in the serializer. If you
override the scope using "serialization_scope" in your controller,
it will use that method name instead.
2013-03-18 14:44:38 -04:00
Sam
ad1d34b2c4
Fix inheritance issues, poison cache if attributes change
2013-03-16 03:45:06 -07:00
Bartek Borkowski
00b5739d38
Add mutual association test
2013-03-15 18:59:05 +01:00
Steve Klabnik
746a63ab09
Merge pull request #89 from twinturbo/caching
...
Serializers Cache JSON & Hashes
2013-03-15 10:30:04 -07:00
Tony Pitale
d3c6596990
make sure to merge the original responder options into the given options to preserve location
2013-03-15 03:54:35 -04:00
twinturbo
4a5e1e1ae5
Attemp to fix bad test
2013-03-15 08:41:39 +01:00
twinturbo
c3966fe741
ArraySerializer is also cached
2013-03-14 22:54:05 +01:00
twinturbo
e3888f0a40
Clean up interface inconistency
2013-03-14 22:40:06 +01:00
twinturbo
535a33a33b
Have to opt in with #cache_key
2013-03-14 22:40:06 +01:00
twinturbo
e923174a26
#cache_key delegates to #object by default
2013-03-14 22:40:06 +01:00
twinturbo
b4395f281b
Add basic caching
2013-03-14 22:40:06 +01:00
Michael Rykov
37b0690fb8
Add a Responder to handle respond_with(resource)
2013-03-13 16:45:23 -07:00
Steve Klabnik
f4916f113f
Merge pull request #223 from tchak/id-serialization-with-hooks
...
use `read_attribute_for_serialization` to serialize ids
2013-03-08 09:17:19 -08:00
Steve Klabnik
e76a16486f
Merge pull request #170 from FundingGates/master
...
Support optional types for computed attributes
2013-03-08 09:11:29 -08:00