mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Make Model#dup copy the attributes too.
Otherwise, #dup-ing yourself and operating on a copy isn't enough to ensure your own state remains untouched. For example, AWS::Storage::Files#each will only work once without this change, since even though the object operates on a copy of itself, its 'marker' attribute winds up getting changed because @attributes is shared with the copy.
This commit is contained in:
parent
1827f00c3a
commit
4630f2e43f
1 changed files with 10 additions and 0 deletions
|
@ -121,6 +121,12 @@ module Fog
|
|||
@attributes ||= {}
|
||||
end
|
||||
|
||||
def dup
|
||||
copy = super
|
||||
copy.attributes = attributes.dup
|
||||
copy
|
||||
end
|
||||
|
||||
def identity
|
||||
send(self.class.instance_variable_get('@identity'))
|
||||
end
|
||||
|
@ -165,6 +171,10 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
attr_writer :attributes
|
||||
|
||||
private
|
||||
|
||||
def remap_attributes(attributes, mapping)
|
||||
|
|
Loading…
Reference in a new issue