File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed
lib/active_model/serializer Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change 1
1
module ActiveModel
2
2
class Serializer
3
3
module Attributes
4
+ # @api private
4
5
class Attribute
5
6
delegate :call , to : :reader
6
7
@@ -19,12 +20,14 @@ def self.build(name, block)
19
20
end
20
21
end
21
22
end
23
+ # @api private
22
24
class AttributeReader < Attribute
23
25
def initialize ( name )
24
26
super ( name )
25
27
@reader = -> ( instance ) { instance . read_attribute_for_serialization ( name ) }
26
28
end
27
29
end
30
+ # @api private
28
31
class AttributeBlock < Attribute
29
32
def initialize ( name , block )
30
33
super ( name )
Original file line number Diff line number Diff line change @@ -35,10 +35,12 @@ def initialize(*)
35
35
@reader = self . class . build_reader ( name , block )
36
36
end
37
37
38
+ # @api private
38
39
def value ( instance )
39
40
call ( instance )
40
41
end
41
42
43
+ # @api private
42
44
def self . build_reader ( name , block )
43
45
if block
44
46
-> ( instance ) { instance . read_attribute_for_serialization ( name ) . instance_eval ( &block ) }
You can’t perform that action at this time.
0 commit comments