Shishir Kakaraddi
cc7f88843a
Merge pull request #331 from larissa/set-id-block
...
Allow block for id customization
2018-11-03 11:37:56 -07:00
Shishir Kakaraddi
326f9784ca
Merge pull request #294 from nikz/add-links-option-to-relationship-serializer
...
Adds a :links option to the relationship macros
2018-11-03 11:35:39 -07:00
Maros Hluska
d5ea95370f
Fix params not being hash by default
2018-10-18 22:59:33 +07:00
Shishir Kakaraddi
ece607af5f
Merge pull request #326 from gorenje/spec_for_has_one_through
...
added spec for has_one-through relationship
2018-10-14 08:32:44 -07:00
Larissa Reis
9fa26fa588
Allow block for id customization
...
Allow an ID of object to be customized directly on the serializer by
passing a block to `set_id` as opposed to only through a model property.
We already allow for attributes that do not have a model property of the
same name to be customized directly on the serializer using a block.
This customization can be useful in situation in which you have
different classes being serialized using the same serializer. For
example, if we have `HorrorMovie`, `ComedyMovie` and `DramaMovie` using
the same `MovieSerializer`, we can unify their IDs using
```
class MovieSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :year
set_id do |record|
"#{record.name.downcase}-#{record.id}"
end
```
which is preferable to creating a `#serialized_id` method in every model
that will use `MovieSerializer` to encapsulate the customization.
Closes #315
2018-10-10 22:26:57 -06:00
nikz
1ad20d6b7b
Merge branch 'upstream-dev' into add-links-option-to-relationship-serializer
2018-10-07 21:29:43 +01:00
nikz
85b41c45d4
Adds :lazy_load_data option
...
If you include a default empty `data` option in your JSON API response,
many frontend frameworks will ignore your `related` link that could be
used to load relationship records, and will instead treat the
relationship as empty.
This adds a `lazy_load_data` option which will:
* stop the serializer attempting to load the data and;
* exclude the `data` key from the final response
This allows you to lazy load a JSON API relationship.
2018-10-07 21:23:36 +01:00
Austin Matzko
1ab5cd387a
Don't share data_links among inherited serializers.
2018-10-03 17:51:37 -04:00
Gerrit Riessen
9bff454806
added spec for has_one-through relationship
2018-09-26 12:03:29 +02:00
Shishir Kakaraddi
11b5255010
Merge pull request #313 from sakuraineed/fix_set_key_transform
...
Fix set_key_transform's set_type to give priority to pre-set value
2018-09-19 21:56:59 -07:00
Shishir Kakaraddi
fced516356
transforms type for polymorphic relationships too
2018-09-19 20:24:40 -07:00
Kenji Sakurai
64f7b6c50d
Add spec for singular and plural, so remove same checking example.
2018-09-16 14:18:10 +09:00
Kenji Sakurai
57f09c7d71
Fix method order in spec after
2018-09-10 11:07:06 +09:00
Kenji Sakurai
6dc34cd4d4
Fix set_key_transform's set_type to give priority to pre-set value
2018-09-08 23:48:44 +09:00
François Pradel
955f4f234d
Add support for polymorphic includes
2018-08-31 19:17:45 -07:00
Igor Khodyrev
e3c45d9b1b
Fix weak entities case (id is not meaningful attribute) with include.
2018-08-22 20:05:51 -07:00
nikz
ef04bc377e
Removes Hash#dig usage
2018-08-05 21:03:13 +01:00
Nik Wakelin
100f850416
Merge branch 'dev' into add-links-option-to-relationship-serializer
2018-08-05 20:58:39 +01:00
nikz
89f007d069
Adds a :links option to the relationship macros
...
This allows specifying a `:links` option to a has_many/has_one
relationship, which means you can specify `self` or `related` links as
per the JSON API spec (these are often useful for not loading all
associated objects in a single payload)
2018-08-05 20:37:44 +01:00
Shishir Kakaraddi
a5414c6b8f
Merge pull request #280 from manojmj92/add_meta
...
Introduce the ability to add `meta` tag for every resource in the collection
2018-07-23 13:30:39 -07:00
Manoj M J
6d03db3a0c
Merge branch 'dev' into master
2018-07-21 10:06:56 +05:30
Manoj M J
099eb606bd
Merge branch 'dev' into add_meta
2018-07-21 09:39:33 +05:30
Manoj M J
dd71bc15d6
Introduce the ability to add meta tag for every resource in the collection
2018-07-20 10:33:27 +05:30
Trevor Hinesley
dfcbe263fb
Merge branch 'master' into params-in-nested-includes
2018-07-19 09:58:25 -05:00
Trevor Hinesley
07b6e614ac
Params are now passed to nested includes
2018-07-19 09:57:22 -05:00
Manoj M J
9c659839e4
Evaluate ids via the specified ‘id_method_name’ when relationships are evaluated via a block
2018-07-19 15:40:20 +05:30
Erol
e2bf5411a2
Set the record type for inherited serializers
2018-07-16 21:10:10 -07:00
Erol
e683bbfb78
Update spec with included documents with no explicitly given fields
2018-07-16 21:10:10 -07:00
Erol
a363c90bfb
Allow the serializer to return sparse fieldsets
2018-07-16 21:10:10 -07:00
Erol
e05193fb5e
Add spec for proc methods with optional arguments
2018-07-16 21:10:10 -07:00
Erol
449c1bf05f
Allow passing procs with variable arguments when declaring an attribute
2018-07-16 21:10:10 -07:00
Oleksiy Babich
ecb92f07f5
add is_collection parameter to force corresponding serialization ( #239 )
...
* add is_collection parameter to force corresponding serialization
* add documentation for is_collection purpose, behavior
and notes re. default autodetect logic
2018-07-03 19:35:06 -07:00
Kyle Reeves
01477e9c5b
fix relationship id_hash method
2018-07-03 19:33:34 -07:00
Kyle Reeves
d47b74f71f
all tests are passing, but still need to write tests for relationship class
2018-07-03 19:33:34 -07:00
Kyle Reeves
7b23adddc4
working on new relationship class
2018-07-03 19:33:34 -07:00
Trevor Hinesley
f864099761
Conditional relationships should be removed from included when proc evaluates to false
2018-07-03 19:33:34 -07:00
Kyle Reeves
0b70657a41
update test for conditional relationships
2018-07-03 19:33:34 -07:00
Kyle Reeves
5558dcd703
allow conditional relationships
2018-07-03 19:33:34 -07:00
Darren Johnson
4a333d7276
Set type value when setting key transform
2018-06-21 18:40:24 -07:00
Trevor Hinesley
5c820695b3
Split attribute serialization into its own class
2018-06-21 18:38:42 -07:00
Trevor Hinesley
bad004fd42
Allow conditional attributes
2018-06-21 18:38:42 -07:00
homer
44d5e0f9c5
Fix serialization for nested nil includes with block
2018-05-31 17:16:54 -07:00
Shishir Kakaraddi
cd1bc0968e
dont create a object for a has one relationship unnecessarily just to fetch id
2018-05-20 15:11:07 -07:00
Shishir Kakaraddi
ea5296ac25
making object level links similar to attributes
2018-05-20 15:08:47 -07:00
Jodi Showers
74f27ccdf0
Links within data ( #161 )
2018-05-20 13:14:46 -07:00
Ryan O'Donnell
b090391551
Fix serialization for nested nil includes
2018-05-18 19:06:16 -07:00
Les Fletcher
077817ecec
fix skylight normalizers issue
2018-05-16 18:43:05 -07:00
Shishir Kakaraddi
3fb975602b
fixes some unnecessary performance test failures
2018-05-14 19:27:50 -07:00
Shishir Kakaraddi
00d3aa4997
adding NotImplementedError when trying to include polymorphic relationships
2018-05-10 23:22:21 -07:00
Jodi Showers
3ebf34928c
Serialize nested includes ( #152 )
2018-05-10 21:17:32 -07:00