Use Ruby's initialize_copy for clone/dup
Ruby provides a method for implementing deep-copy on objects called initialize_copy. This gets called after a clone or dup, and is the more idiomatic way to handle the sort of thing being done in the previously-defined clone method.
This commit is contained in:
parent
949bb42a4d
commit
129f2da60a
|
@ -19,11 +19,10 @@ module AASM
|
|||
@config = OpenStruct.new
|
||||
end
|
||||
|
||||
def clone
|
||||
klone = super
|
||||
klone.states = states.clone
|
||||
klone.events = events.clone
|
||||
klone
|
||||
def initialize_copy(orig)
|
||||
super
|
||||
@states = @states.dup
|
||||
@events = @events.dup
|
||||
end
|
||||
|
||||
def create_state(name, options)
|
||||
|
|
Loading…
Reference in New Issue