@@ -15,9 +15,9 @@ module Attributes
1515 # by the serializer.
1616 def attributes ( requested_attrs = nil , reload = false )
1717 @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 )
2121 end
2222 end
2323 end
@@ -53,25 +53,25 @@ def attributes(*attrs)
5353 # end
5454 def attribute ( attr , options = { } , &block )
5555 key = options . fetch ( :key , attr )
56- _attributes_data [ attr ] = Attribute . new ( attr , key , block )
56+ _attributes_data [ key ] = Attribute . new ( attr , block )
5757 end
5858
5959 # @api private
6060 # keys of attributes
6161 # @see Serializer::attribute
6262 def _attributes
63- _attributes_data . values . map ( & :key )
63+ _attributes_data . keys
6464 end
6565
6666 # @api private
6767 # maps attribute value to explict key name
6868 # @see Serializer::attribute
6969 # @see Adapter::FragmentCache#fragment_serializer
7070 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 }
7575 end
7676 end
7777 end
0 commit comments