File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 3
3
Breaking changes:
4
4
Features:
5
5
Fixes:
6
+ - [ #1501 ] ( https://github.com/rails-api/active_model_serializers/pull/1501 ) Adds tests for SerializableResource::use_adapter?,doc typos (@domitian )
6
7
- [ #1488 ] ( https://github.com/rails-api/active_model_serializers/pull/1488 ) Require ActiveSupport's string inflections (@nate00 )
7
8
Misc:
8
9
Original file line number Diff line number Diff line change @@ -56,15 +56,15 @@ High-level overview:
56
56
- ` :each_serializer ` specifies the serializer for each resource in the collection.
57
57
- For a single resource, the ` :serializer ` option is the resource serializer.
58
58
- Options are partitioned in serializer options and adapter options. Keys for adapter options are specified by
59
- [ ` ADAPTER_OPTIONS ` ] ( https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/serializable_resource.rb#L4 ) .
59
+ [ ` ADAPTER_OPTION_KEYS ` ] ( https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/serializable_resource.rb#L4 ) .
60
60
The remaining options are serializer options.
61
61
62
62
Details:
63
63
64
64
1 . ** ActionController::Serialization**
65
65
1 . ` serializable_resource = ActiveModel::SerializableResource.new(resource, options) `
66
66
1 . ` options ` are partitioned into ` adapter_opts ` and everything else (` serializer_opts ` ).
67
- The adapter options keys for the are defined by ` ADAPTER_OPTIONS ` .
67
+ The ` adapter_opts ` keys are defined in ` ActiveModel::SerializableResource::ADAPTER_OPTION_KEYS ` .
68
68
1 . ** ActiveModel::SerializableResource**
69
69
1 . ` if serializable_resource.serializer? ` (there is a serializer for the resource, and an adapter is used.)
70
70
- Where ` serializer? ` is ` use_adapter? && !!(serializer) `
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ def self.serializers_cache
67
67
68
68
# @api private
69
69
# Find a serializer from a class and caches the lookup.
70
- # Preferentially retuns :
70
+ # Preferentially returns :
71
71
# 1. class name appended with "Serializer"
72
72
# 2. try again with superclass, if present
73
73
# 3. nil
Original file line number Diff line number Diff line change @@ -23,5 +23,13 @@ def test_serializable_resource_delegates_as_json_to_the_adapter
23
23
options = nil
24
24
assert_equal @adapter . as_json ( options ) , @serializable_resource . as_json ( options )
25
25
end
26
+
27
+ def test_use_adapter_with_adapter_option
28
+ assert ActiveModel ::SerializableResource . new ( @resource , { adapter : 'json' } ) . use_adapter?
29
+ end
30
+
31
+ def test_use_adapter_with_adapter_option_as_false
32
+ refute ActiveModel ::SerializableResource . new ( @resource , { adapter : false } ) . use_adapter?
33
+ end
26
34
end
27
35
end
You can’t perform that action at this time.
0 commit comments