As the project has been renamed, its better to reflect it in the source
code as well.
JSONAPI::Serializer is evaluated from FastJsonapi::ObjectSerializer so
this change probably will go unnoticed in gem usage.
This change alters the cache namespace prior to retrieving cached record
data to ensure that different fieldsets are given different cache keys.
Previously, all cache keys for the same record would be specified
identically, leading to a situation where the fieldset would be ignored
if record caching is enabled.
Fixes#90.
* fix(ObjectSerializer): pass to_json arguments
to_json takes arguments that serialized_json did not define. This breaks a lot of things.
* Update CHANGELOG.md with latest fix and release
- Very explicit where caching is stored
- No `Rails.cache` automagic with possible colliding keys
- Rails 5.2+ cache versioning support
- Implicit namespace support (by cache instance, e.g.
ActiveSupport::Cache::MemoryStore.new(namespace: 'jast_jsonapi')
- All cache instance options are supported
* allow the relationship's serializer key to be a Proc
* fixes
* specifically test the relationship name and the resource type
* support object blocks without a serializer defined
* stop validation gracefully if the relationship is polymorphic
* improve performance by using instance variables instead of accessor methods
* force initialization up front to avoid the iterative calls
* serializer procs should act like polymorphic when determining the id_method_name
* specs for serializer procs
* updated with more details and examples for relationship serializer options
* adjust specs to define the serializers
* avoid extra method calls for performance
* name change
* one less function call for better performance
* do not require lazy loaded relationships to resolve the serializer
* give polymorphic precedence for backwards compatibility
* move serializer inference into ObjectSerializer to allow for overriding
* move method for better diff
* fix race condition in multi-threaded environments
* Add params to set_id block arguments
Pull request #331 added a block to the ObjectSerializer.set_id class
method, which allows passing a block to the set_id method. Currently
this block takes only one argument `record`:
```
set_id do |record|
"#{record.name.downcase}-#{record.id}"
end
```
This PR adds another argument `params` to the block:
```
set id do |record, params|
params[:admin] ? record.id : "#{record.name.downcase}-#{record.id}"
end
```
This customization can be useful in situation where we serve different
clients that may need different IDs. One nice side effect is also that
the `set_id` method has the same method signature as the `attribute`
method.
* Update the README