Skip to content

Commit 19ecd4a

Browse files
committed
Style
1 parent 3995777 commit 19ecd4a

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/active_model/serializer/association.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ def meta
4646
end
4747

4848
def object
49-
@object ||= @wip_isolated_options[:association_options].fetch(:reflection).
50-
value(
51-
@wip_isolated_options[:association_options].fetch(:parent_serializer),
52-
@wip_isolated_options[:association_options].fetch(:include_slice)
53-
)
49+
@object ||= @wip_isolated_options[:association_options].fetch(:reflection)
50+
.value(
51+
@wip_isolated_options[:association_options].fetch(:parent_serializer),
52+
@wip_isolated_options[:association_options].fetch(:include_slice)
53+
)
5454
end
55-
alias eval_reflection_block object
55+
alias_method :eval_reflection_block, :object
5656

5757
def include_data?
5858
eval_reflection_block if @wip_isolated_options[:association_options].fetch(:reflection).block
59-
@wip_isolated_options[:association_options].fetch(:reflection).
60-
include_data?(@wip_isolated_options[:association_options].fetch(:include_slice))
59+
@wip_isolated_options[:association_options].fetch(:reflection)
60+
.include_data?(@wip_isolated_options[:association_options].fetch(:include_slice))
6161
end
6262

6363
# @return [ActiveModel::Serializer, nil]
@@ -93,6 +93,8 @@ def serialize_object!(object)
9393
end
9494
end
9595

96+
# NOTE(BF): This serializer throw/catch should only happen when the serializer is a collection
97+
# serializer. This is a good reason for the reflection to have a to_many? type method.
9698
def instantiate_serializer(object)
9799
serializer = catch(:no_serializer) do
98100
serializer_options = @wip_isolated_options[:association_options].fetch(:parent_serializer_options).except(:serializer)

test/serializers/associations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def setup
380380

381381
test 'a serializer inheriting from another serializer can have an additional association with the same name but with different key' do
382382
expected = [:author, :comments, :blog, :reviews].sort
383-
result = @inherited_post_serializer.associations.map { |a| a.key }.sort
383+
result = @inherited_post_serializer.associations.map(&:key).sort
384384
assert_equal(result, expected)
385385
end
386386
end

0 commit comments

Comments
 (0)