Skip to content

Commit

Permalink
Merge pull request aasm#51 from ernie/intialize-copy
Browse files Browse the repository at this point in the history
Use Ruby's initialize_copy for clone/dup
  • Loading branch information
alto committed Jun 28, 2012
2 parents 949bb42 + 129f2da commit 2139407
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/aasm/state_machine.rb
Expand Up @@ -3,11 +3,11 @@ class StateMachine
def self.[](clazz)
(@machines ||= {})[clazz.to_s]
end

def self.[]=(clazz, machine)
(@machines ||= {})[clazz.to_s] = machine
end

attr_accessor :states, :events, :initial_state, :config
attr_reader :name

Expand All @@ -19,11 +19,10 @@ def initialize(name)
@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)
Expand Down

0 comments on commit 2139407

Please sign in to comment.