Commit Graph

72 Commits

Author SHA1 Message Date
Ivan Yurov
2dd569ae51 Add Serializer 'type' directive to control type field, for use by the JsonApi adapter 2015-10-01 22:48:57 -04:00
Benjamin Fleischer
19de5f7722 Introduce Adapter::Base
Breaking change:
- Adapters now inherit Adapter::Base
- 'Adapter' is now a module, no longer a class
Why?

- using a class as a namespace that you also inherit from is complicated and circular at time i.e.
  buggy (see https://github.com/rails-api/active_model_serializers/pull/1177)
- The class methods on Adapter aren't necessarily related to the instance methods, they're more
    Adapter functions
- named `Base` because it's a Rails-ism
- It helps to isolate and highlight what the Adapter interface actually is
2015-09-20 12:26:04 -05:00
Lucas Hosseini
ce7a839f3d Extended format for JSONAPI include option. 2015-09-13 22:45:47 +02:00
Lucas Hosseini
890003b305 Minor style improvements. 2015-09-07 09:06:17 +02:00
Lucas Hosseini
ebb05959d3 Merge remote-tracking branch 'upstream/master' into improve-tests 2015-09-07 09:03:17 +02:00
Benjamin Fleischer
228cc1c92a Rubocop: Consistent spacing 2015-09-03 20:51:40 -05:00
Benjamin Fleischer
bdfe13c527 Style/StringLiterals single quote all the things 2015-09-03 20:50:45 -05:00
Lucas Hosseini
4bba16bf4e Factor with_adapter + force cache clear before each test. 2015-08-28 17:00:24 +02:00
Lucas Hosseini
91235ba7bc Add configuration option to set resource type to singular/plural with jsonapi. 2015-08-24 22:55:22 +02:00
Bruno Bacarini
d50262edbe test pagination links the way the controller does 2015-08-20 11:32:03 -03:00
Bruno Bacarini
01eab3bdb4 send whole request context to model serializer 2015-08-19 10:48:48 -03:00
Bruno Bacarini
2c2f948fa0 Add pagination links automatically
Pagination links will be included in your response automatically as long
as the resource is paginated using Kaminari or WillPaginate
and if you are using a JSON-API adapter. The others adapters does not have this feature.
2015-08-18 19:04:04 -03:00
Bruno Bacarini
a41d90cce4 add self to pagination links 2015-08-18 19:04:04 -03:00
Bruno Bacarini
e0d050d2af remove resource and options attr_reader from array_serialize 2015-08-18 19:04:03 -03:00
Bruno Bacarini
7be25fef14 include query_parameters on pagination links as well 2015-08-18 19:04:03 -03:00
Bruno Bacarini
e62a7d6f34 return complete URIs on pagination links 2015-08-18 19:04:03 -03:00
Bruno Bacarini
331218d1c3 add test to class of pagination links 2015-08-18 19:04:03 -03:00
Rodrigo Ra
df63b59512 Add key option to serializer associations 2015-07-05 19:47:58 -03:00
Hugo Almeida
f25071ca70 Fixes virtual value not being used 2015-06-29 10:48:12 +09:00
João Moura
741c4a4b51 updating tests to work with new virtual_value implementation 2015-06-26 02:16:35 -03:00
Benjamin Fleischer
cf77786da2 Fix #955 2015-06-26 02:16:34 -03:00
Justin Aiken
3710c32cee Add some failing tests around has_many assocs...
..where no serializer is defined for the thing that is has_many'd
2015-06-26 02:16:34 -03:00
João Moura
1ea5608e78 updating tests to match new adapters structure 2015-06-15 13:39:36 -03:00
Lachlan Sylvester
97e82c3eb7 use model name to determine the type 2015-06-13 19:45:46 +10:00
Benedikt Deicke
4f576a1463 Adjusts JsonApi adapter to serialize relationships in a nested relationships hash 2015-05-21 16:35:35 +02:00
Benedikt Deicke
ca41901fb8 Adjusts JsonApi adapter to serialize attributes in a nested attributes hash 2015-05-21 16:23:01 +02:00
Alexandre de Oliveira
168c36fc7d Merge pull request #810 from joaomdmoura/fragment-cache
Adding Fragment Cache to AMS
2015-04-21 17:57:55 -03: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
Yohan Robert
6a0564a241 Fixed a bug that appears when a nil association is included 2015-04-03 12:50:05 +02:00
Mateo Murphy
5e560ddbef Fix skipped test and add test for duplicate links 2015-03-24 19:46:30 -04:00
Mateo Murphy
33f3a88ba0 Implement included and id and type as per spec 2015-03-22 20:43:56 -04:00
Mateo Murphy
d82c599c68 Always use plural for linked types
Although spec is agnostic about inflection rules, examples given are plural
2015-03-22 20:43:11 -04:00
Mateo Murphy
0f55f21266 Update format of links 2015-03-22 20:41:20 -04:00
Mateo Murphy
da86747a3e Use symbol for root in jsonapi, fix tests 2015-03-22 20:38:29 -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
Robbie Pitts
ad5677c4ec Make json api adapter 'include' option accept an array, accommodate comma delimited string for legacy reasons 2015-03-11 10:01:44 -04:00
Gary Gordon
c6044286ef Workaround order dependent test failure 2015-03-01 13:47:40 -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
Alexandre de Oliveira
77fb050d24 Merge pull request #821 from wjordan/patch-1
Fix explicit serializer for associations
2015-03-01 08:46:27 -05:00
Alexandre de Oliveira
3505bc64a3 Merge pull request #798 from donbobka/feature/fix_lost_test
Fix lost test `test_include_multiple_posts_and_linked`
2015-03-01 08:41:13 -05:00
Will Jordan
f4eb33d6e9 Update test_includes_linked_comments with correct expected result 2015-02-24 18:46:04 -08: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
Vladimir Lyzo
54d6696e7c Fix lost test test_include_multiple_posts_and_linked 2015-01-31 19:44:22 +03: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
Guillermo Iguaran
22202a115a Lets keep the assert_equal without parens for consistency. 2015-01-11 16:21:20 -05:00
Robbie Pitts
b626ec8f14 Spec for linked resource type name demodulization 2015-01-11 16:10:02 -05: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
Aaron Renoir
2ed52f96a6 merge upstream update fieldset 2014-11-13 17:45:47 -08:00
Alexandre de Oliveira
2f5626d616 Fixes nested has_many links in JSONAPI
When linked resource had has_many links, all of them would use the
association from the first resource, causing all of the items to build
`links` with the same associations.

This fixes it by iterating over the serializers, not just the
attributes array.
2014-11-13 16:38:47 -02:00