Get rid of class vars added to classes including AASM, support inheritance on AASMs
This commit is contained in:
parent
08d129c46d
commit
216b48e519
|
@ -11,6 +11,12 @@ module AASM
|
|||
base.extend AASM::ClassMethods
|
||||
AASM::Persistence.set_persistence(base)
|
||||
AASM::StateMachine[base] = AASM::StateMachine.new('')
|
||||
|
||||
base.class_eval do
|
||||
def base.inherited(klass)
|
||||
AASM::StateMachine[klass] = AASM::StateMachine[self].dup
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
|
|
@ -29,8 +29,16 @@ end
|
|||
|
||||
class Bar
|
||||
include AASM
|
||||
|
||||
aasm_state :read
|
||||
aasm_state :ended
|
||||
|
||||
aasm_event :foo do
|
||||
transitions :to => :ended, :from => [:read]
|
||||
end
|
||||
end
|
||||
|
||||
class Baz < Bar
|
||||
end
|
||||
|
||||
|
||||
|
@ -251,3 +259,14 @@ describe AASM, '- state actions' do
|
|||
foo.close
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe Baz do
|
||||
it "should have the same states as it's parent" do
|
||||
Baz.aasm_states.should == Bar.aasm_states
|
||||
end
|
||||
|
||||
it "should have the same events as it's parent" do
|
||||
Baz.aasm_events.should == Bar.aasm_events
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue