@@ -15,9 +15,9 @@ module Attributes
15
15
# by the serializer.
16
16
def attributes ( requested_attrs = nil , reload = false )
17
17
@attributes = nil if reload
18
- @attributes ||= self . class . _attributes_data . values . each_with_object ( { } ) do |attr , hash |
19
- next unless requested_attrs . nil? || requested_attrs . include? ( attr . key )
20
- hash [ attr . key ] = attr . value ( self )
18
+ @attributes ||= self . class . _attributes_data . each_with_object ( { } ) do |( key , attr ) , hash |
19
+ next unless requested_attrs . nil? || requested_attrs . include? ( key )
20
+ hash [ key ] = attr . value ( self )
21
21
end
22
22
end
23
23
end
@@ -53,25 +53,25 @@ def attributes(*attrs)
53
53
# end
54
54
def attribute ( attr , options = { } , &block )
55
55
key = options . fetch ( :key , attr )
56
- _attributes_data [ attr ] = Attribute . new ( attr , key , block )
56
+ _attributes_data [ key ] = Attribute . new ( attr , block )
57
57
end
58
58
59
59
# @api private
60
60
# keys of attributes
61
61
# @see Serializer::attribute
62
62
def _attributes
63
- _attributes_data . values . map ( & :key )
63
+ _attributes_data . keys
64
64
end
65
65
66
66
# @api private
67
67
# maps attribute value to explict key name
68
68
# @see Serializer::attribute
69
69
# @see Adapter::FragmentCache#fragment_serializer
70
70
def _attributes_keys
71
- _attributes_data . values
72
- . each_with_object ( { } ) do |attr , hash |
73
- next if attr . key == attr . name
74
- hash [ attr . name ] = { key : attr . key }
71
+ _attributes_data
72
+ . each_with_object ( { } ) do |( key , attr ) , hash |
73
+ next if key == attr . name
74
+ hash [ attr . name ] = { key : key }
75
75
end
76
76
end
77
77
end
0 commit comments