Commit Graph

52 Commits

Author SHA1 Message Date
Bernard Potocki
c91b649504 Allow to define custom serializer for given class by defining #serializer_class method in serialized object's class. Resolves #515. 2015-05-03 17:47:52 +02:00
João Moura
792fb8a905 Adding Fragment Cache to AMS
It's an upgrade based on the new Cache implementation #693.
It allows to use the Rails conventions to cache
specific attributes or associations.
It's based on the Cache Composition implementation.
2015-04-05 18:19:57 -03:00
Mateo Murphy
33f3a88ba0 Implement included and id and type as per spec 2015-03-22 20:43:56 -04:00
Guillermo Iguaran
b68d7f4826 Merge pull request #852 from mateomurphy/serializer-options-fix
Fix options merge order in `each_association`
2015-03-22 18:54:07 -05:00
Mateo Murphy
03372ea61d Fix options merge order in each_association
Custom association serializers were getting clobbered when using an each serializer.
2015-03-20 00:22:46 -04:00
Mateo Murphy
ca985e1afd Use association value for determining serializer used
Ensures overridden association value works when orignal association does not return a result.
2015-03-19 23:28:00 -04:00
Alexandre de Oliveira
0446a9714d Merge pull request #833 from lsylvester/cache-serializers-for-class
Cache serializers for class
2015-03-13 19:55:49 -03:00
Alexandre de Oliveira
af81a403e3 Passes serializer options down into associations 2015-03-11 16:37:14 -03:00
Alexandre de Oliveira
48650ecf7e Makes passed in options accessible inside serializers
In some cases, we want to pass arguments from the controller and we want
to serializer a resource according to that. This allows serializers to
use the `options` method to retrieve whatever was passed in via
arguments.
2015-03-11 14:53:57 -03:00
Lachlan Sylvester
980d1ced81 add explicit thread_safe dependency 2015-03-11 11:15:17 +11:00
lsylvester
2b0c5ee084 clear the cache between requests 2015-03-11 09:53:47 +11:00
lsylvester
3fb560908e cache the serializers for a class 2015-03-11 09:53:47 +11:00
Guillermo Iguaran
d55f3b33b4 Merge pull request #811 from mateomurphy/scope
Reimplement serialization scope and scope_name
2015-03-10 10:16:06 -05:00
Gary Gordon
651b99f22e Support has_one to be compatible with 0.8.x
Update README and CHANGELOG
2015-03-01 13:47:34 -05:00
Will Jordan
f2ee544a88 Fix explicit serializer for associations 2015-02-24 16:01:43 -08:00
Mateo Murphy
2962f3f64e Reimplement serialization scope and scope_name 2015-02-09 11:24:41 -05:00
Joao Moura
8a432ad2b3 Adding cache support to version 0.10.0
It's a new implementation of cache based on ActiveSupport::Cache.
The implementation abstracts the cache in Adapter class on a
private method called cached_object, this method is intended
to be used on Adapters inside serializable_hash method in order
to cache each instance of the object that will be returned by
the serializer.

Some of its features are:
- A different syntax. (no longer need the cache_key method).
- An options argument that have the same arguments of ActiveSupport::Cache::Store, plus a key option that will be the prefix of the object cache on a pattern "#{key}-#{object.id}".
- It cache the objects individually and not the whole Serializer return, re-using it in different requests (as a show and a index method for example.)
2015-02-02 14:53:34 -02:00
Alexandre de Oliveira
e47231cdc8 Support overriding association methods
You can override associations to define custom scope on them.
2015-01-29 16:52:18 -02:00
Alexandre de Oliveira
6eb75af96b Merge pull request #696 from ggordon/explicit_serializer
Explicitly set serializer for associations
2015-01-06 09:57:07 -02:00
Alexandre de Oliveira
87f817943a Merge pull request #700 from arenoir/sparse_fieldsets
sparse fieldsets
2015-01-06 09:38:51 -02:00
Alexandre de Oliveira
bd27da1b76 Adds support for meta attribute
Currently, 0.10.0.pre doesn't support `meta` option in `render`. This
way, there's no way to support features such as pagination. `0.9` had
this feature in place.

This adds support for it, as well as fixes small things in README.md.

This won't support `meta` in array responses because arrays don't have
keys, obviously. Also, the response should have a `root` key, otherwise
no `meta` will be included.

In some cases, for example using JsonApi, ArraySerializer will result in
a response with a `root`. In that case, `meta` will be included.
2015-01-05 02:56:33 -02:00
Joakim Ekström
9768da7a70 Missing a word 2014-12-04 17:05:10 +01:00
Aaron Renoir
2ed52f96a6 merge upstream update fieldset 2014-11-13 17:45:47 -08:00
Gary Gordon
5560b49098 Allow overriding the adapter with render option
Make it easy to use multiple adapters in an app.

use "adapter: false" to not use ams

make a test override config.adapter
2014-11-13 10:23:19 -05:00
Gary Gordon
9f9715801a Explicitly set serializer for associations
Document specifying serializer for assocaition
2014-11-13 10:17:59 -05:00
Gary Gordon
08716d20c9 Rename attribute with :key (0.8.x compatibility) 2014-11-13 08:03:22 -05:00
Aaron Renoir
c9c58e31e5 merge upstream/master 2014-11-05 16:47:15 -08:00
Guillermo Iguaran
19ac139880 Handle correctly null associations
null belongs_to associations are now serialized as nil instead
of raise an error during serialization.
2014-10-30 09:35:05 -05:00
Aaron Renoir
39bee48ae6 implement sparse fieldsets http://jsonapi.org/format/#fetching-sparse-fieldsets 2014-10-26 13:04:14 -07:00
Steve Klabnik
099f773a65 Merge pull request #625 from JordanFaust/feature/url-dsl
Add DSL for urls
2014-10-14 11:47:14 -04:00
Steve Klabnik
341cca7d8a Merge pull request #681 from quainjn/inherited-serializer
Check superclasses for Serializers
2014-10-14 11:36:02 -04:00
Jake Quain
c0166f3026 Check superclasses for Serializers 2014-10-13 17:39:54 -06:00
NullVoxPopuli
7338b62b02 add support for root keys
remove debugging gem

fix white space
2014-10-13 13:27:09 -04:00
Jordan Faust
ad0859e262 Add DSL for urls 2014-09-01 13:44:22 -05:00
Tema Bolshakov and Dmitry Myaskovskiy
71a43a432a Pass options to associations 2014-08-29 20:16:11 +04:00
Tema Bolshakov and Dmitry Myaskovskiy
258b5953e2 clean up code 2014-08-29 19:47:46 +04:00
Tema Bolshakov and Dmitry Myaskovskiy
45a47a1c4d safe_constantize instead of rescue 2014-08-29 19:47:29 +04:00
Tema Bolshakov
77847d7c02 User String#constantize instead of Object.const_get 2014-08-29 13:48:06 +04:00
Tema Bolshakov
139609355f Object.const_get differs on 2.0 and 2.1.2. So rescue from NameError 2014-08-29 13:01:01 +04:00
Tema Bolshakov
b4a313e6d8 Merge remote-tracking branch 'upstream/master' into feature/adapter 2014-08-29 12:55:20 +04:00
Tema Bolshakov
e45e5a82b7 Remove 'Adapter' suffix from adapters since they are in Adapter:: namespace 2014-08-29 11:40:56 +04:00
Tema Bolshakov
c1fdfc1cdc First try to implement ArraySerializer 2014-08-28 19:16:24 +04:00
Tema Bolshakov
466c7d5dd8 Wrap association into Serializers 2014-08-28 18:46:19 +04:00
Tony Pitale
dee2f1969e Rails does not support const_defined? in development mode;
Use const_get instead, and rescue NameError
2014-08-27 14:42:41 -04:00
Tema Bolshakov
fa4ee9d645 Add Serializer#associations 2014-08-27 11:21:01 +04:00
Tema Bolshakov
b1f7a5ccda Move Adapter.adapter_for to Serializer.adapter 2014-08-27 11:02:39 +04:00
Tema Bolshakov
f00fe5595d * Rename NullAdapter to SimpleAdapter
* Introduce abstract Adapter class
* Organaze test structure to match convemtions
2014-08-27 08:21:08 +04:00
Tema Bolshakov
d39a3e0aec serializer_for Array 2014-08-26 12:50:47 +04:00
Jordan Faust
00f7cab864 Add DSL for assocations 2014-08-23 15:20:48 -05:00
Steve Klabnik
970b542549 Implement basic rendering
Woo actioncontroller
2014-07-09 17:52:31 -04:00