280 Commits

Author SHA1 Message Date
Srinivas R
3df917f407
Update README.md 2019-06-11 14:59:22 -07:00
Manoj M J
e0228dacdc Add documentation on how to use helper methods in serializers 2019-03-28 21:12:36 -07:00
Manoj M J
a160d6746f Fix Documentation of Meta Per Resource
Some part of the documentation for this got removed during last merge, so fixing it.
2019-03-28 21:11:48 -07:00
Shishir Kakaraddi
fdcaed6f0d
Merge pull request #342 from Netflix/release-1.5
Release 1.5
1.5
2018-11-03 12:32:22 -07:00
Shishir Kakaraddi
ee76e0c69b bump up version to 1.5 2018-11-03 12:11:56 -07:00
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
Shishir Kakaraddi
9d19f32c78
Merge pull request #334 from hmcfletch/fix/as-core_ext-time
require AS core extension for time
2018-11-03 11:30:54 -07:00
Shishir Kakaraddi
a105bac3d9
Merge pull request #336 from coderbydesign/patch-1
Minor fix in README.md
2018-11-03 11:30:35 -07:00
Shishir Kakaraddi
74bb9d6f6d
Merge pull request #339 from mhluska/fix-params-not-being-default
Fix params not being hash by default
2018-11-03 11:30:20 -07:00
Larissa Reis
0ba5f231fe Add set_id block syntax example to README 2018-10-18 22:04:52 -06:00
Maros Hluska
d5ea95370f Fix params not being hash by default 2018-10-18 22:59:33 +07:00
Keith Walsh
dbda6b6153
Update README.md
Resolve minor typo
2018-10-17 09:29:49 -04: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
Shishir Kakaraddi
935fc05beb
Merge pull request #329 from zinosama/improve-readme-with-id_method_name
Improve documentation with id_method_name
2018-10-14 08:31:01 -07:00
Shishir Kakaraddi
f3368dee2d
Merge pull request #330 from matzko/dev
Don't share data_links among inherited serializers.
2018-10-14 08:29:59 -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
Les Fletcher
05ad93084b
require 'active_support/core_ext/numeric/time’
`5.minutes` was failing in the performance spec
2018-10-09 14:53:57 -07: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
be701f3e06 Don't attempt to dup a nil 2018-10-03 17:59:58 -04:00
Austin Matzko
1ab5cd387a Don't share data_links among inherited serializers. 2018-10-03 17:51:37 -04:00
nikz
1efdd3372d Fixes dangling comma and unused param 2018-10-02 22:09:15 +01:00
zino
467024f8fd Improve readme with id_method_name 2018-10-02 11:36:21 -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
92bcab0a3f
Merge pull request #320 from Netflix/release-1.4
Release 1.4
1.4
2018-09-19 21:41:53 -07:00
Shishir Kakaraddi
90e0feef3c Merge branch 'release-1.4' of https://github.com/Netflix/fast_jsonapi into release-1.4 2018-09-19 21:33:01 -07:00
Shishir Kakaraddi
b674909830 bump up version to 1.4 2018-09-19 21:32:56 -07:00
Shishir Kakaraddi
eb15334146
Merge pull request #311 from Netflix/dev
Dev
2018-09-19 21:25:56 -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
Matthew Lanigan
5a70b1a686 Do not use ActiveSupport core extensions
Core extensions do not play well with many other gems; especially
considering that they only seem to be included for one `to_json` call,
they should be avoided.
2018-09-03 12:01:45 -07:00
Orhan Toy
8357acd6a7 [ci skip] Fix punctuation 2018-09-03 12:01:45 -07:00
François Pradel
955f4f234d Add support for polymorphic includes 2018-08-31 19:17:45 -07:00
François Pradel
3973b312a7 Demodulize relationship record class name 2018-08-31 19:17:45 -07:00
Alessandro Dal Grande
42d9203796 Fix confusing error when using include and no relationship was set
If you forgot to set any `has_many` in the serializer and tried to serialize with an `include` you would get:
```
NoMethodError (undefined method `[]' for nil:NilClass):
```

That is not very helpful. Setting the variable with a default case makes sure the right error message gets displayed.
2018-08-22 20:08:04 -07:00
Orhan Toy
4afa5b81d8 [ci skip] Fix punctuation 2018-08-22 20:06:47 -07:00
Igor Khodyrev
e3c45d9b1b Fix weak entities case (id is not meaningful attribute) with include. 2018-08-22 20:05:51 -07:00
Shishir Kakaraddi
2eaaa71bd8
Merge pull request #299 from g13ydson/feature/add_option_key
add the option "key" in customizable options in the README
2018-08-13 18:05:05 -07:00
Gleydson Tavares
ce2c8003ee add the "option key" in customizable options 2018-08-10 13:15:02 -03: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
8eef7a0bb1 Adds README documentation for relationship links 2018-08-05 20:51:56 +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
Shishir Kakaraddi
daf4030bb0
Merge pull request #274 from manojmj92/master
Evaluate ids via the specified 'id_method_name' when relationships are evaluated via a block
2018-07-23 13:26:53 -07:00
Trevor Hinesley
5a5a5e5125 Fixed conditional attributes documentation 2018-07-23 13:23:41 -07:00