File tree Expand file tree Collapse file tree 4 files changed +10
-8
lines changed
lib/active_model/serializer Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ def initialize(serializer, options = {})
16
16
@options = options
17
17
end
18
18
19
- def serializable_hash ( options = { } )
19
+ def serializable_hash ( options = nil )
20
20
raise NotImplementedError , 'This is an abstract method. Should be implemented at the concrete adapter.'
21
21
end
22
22
23
- def as_json ( options = { } )
23
+ def as_json ( options = nil )
24
24
hash = serializable_hash ( options )
25
25
include_meta ( hash ) unless self . class == FlattenJson
26
26
hash
Original file line number Diff line number Diff line change @@ -4,9 +4,10 @@ module ActiveModel
4
4
class Serializer
5
5
class Adapter
6
6
class Json < Adapter
7
- def serializable_hash ( options = { } )
7
+ def serializable_hash ( options = nil )
8
+ options ||= { }
8
9
if serializer . respond_to? ( :each )
9
- @result = serializer . map { |s | FlattenJson . new ( s ) . serializable_hash }
10
+ @result = serializer . map { |s | FlattenJson . new ( s ) . serializable_hash ( options ) }
10
11
else
11
12
@hash = { }
12
13
Original file line number Diff line number Diff line change @@ -15,10 +15,11 @@ def initialize(serializer, options = {})
15
15
end
16
16
end
17
17
18
- def serializable_hash ( options = { } )
18
+ def serializable_hash ( options = nil )
19
+ options = { }
19
20
if serializer . respond_to? ( :each )
20
21
serializer . each do |s |
21
- result = self . class . new ( s , @options . merge ( fieldset : @fieldset ) ) . serializable_hash
22
+ result = self . class . new ( s , @options . merge ( fieldset : @fieldset ) ) . serializable_hash ( options )
22
23
@hash [ :data ] << result [ :data ]
23
24
24
25
if result [ :included ]
@@ -27,7 +28,7 @@ def serializable_hash(options = {})
27
28
end
28
29
end
29
30
else
30
- @hash [ :data ] = attributes_for_serializer ( serializer , @ options)
31
+ @hash [ :data ] = attributes_for_serializer ( serializer , options )
31
32
add_resource_relationships ( @hash [ :data ] , serializer )
32
33
end
33
34
@hash
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ module ActiveModel
2
2
class Serializer
3
3
class Adapter
4
4
class Null < Adapter
5
- def serializable_hash ( options = { } )
5
+ def serializable_hash ( options = nil )
6
6
{ }
7
7
end
8
8
end
You can’t perform that action at this time.
0 commit comments