Skip to content

Commit b6a4ad1

Browse files
committed
Merge pull request #1383 from beauby/simplify-associations
Simplify reflections handling.
2 parents 9909908 + 762f298 commit b6a4ad1

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

lib/active_model/serializer/reflection.rb

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,12 @@ class Serializer
2626
# So you can inspect reflections in your Adapters.
2727
#
2828
Reflection = Struct.new(:name, :options, :block) do
29-
delegate :call, to: :reader
30-
31-
attr_reader :reader
32-
33-
def initialize(*)
34-
super
35-
@reader = self.class.build_reader(name, block)
36-
end
37-
3829
# @api private
3930
def value(instance)
40-
call(instance)
41-
end
42-
43-
# @api private
44-
def self.build_reader(name, block)
4531
if block
46-
->(instance) { instance.read_attribute_for_serialization(name).instance_eval(&block) }
32+
instance.read_attribute_for_serialization(name).instance_eval(&block)
4733
else
48-
->(instance) { instance.read_attribute_for_serialization(name) }
34+
instance.read_attribute_for_serialization(name)
4935
end
5036
end
5137

0 commit comments

Comments
 (0)