File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
lib/active_model/serializer Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,9 @@ def initialize(name, block)
40
40
41
41
# Return the +attributes+ of +object+ as presented
42
42
# by the serializer.
43
- def attributes ( requested_attrs = nil )
44
- self . class . _attribute_mappings . each_with_object ( { } ) do |( key , attribute_mapping ) , hash |
43
+ def attributes ( requested_attrs = nil , reload = false )
44
+ @attributes = nil if reload
45
+ @attributes ||= self . class . _attribute_mappings . each_with_object ( { } ) do |( key , attribute_mapping ) , hash |
45
46
next unless requested_attrs . nil? || requested_attrs . include? ( key )
46
47
hash [ key ] = attribute_mapping . call ( self )
47
48
end
@@ -65,7 +66,6 @@ def attributes(*attrs)
65
66
end
66
67
end
67
68
68
- # TODO: remove the dynamic method definition
69
69
# @example
70
70
# class AdminAuthorSerializer < ActiveModel::Serializer
71
71
# attributes :id, :recent_edits
You can’t perform that action at this time.
0 commit comments