1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

some little renamings

This commit is contained in:
Thorsten Böttger 2011-11-26 01:10:05 +01:00
parent faa4f3a64b
commit 20f4fed777
4 changed files with 8 additions and 7 deletions

View file

@ -116,7 +116,7 @@ module AASM
private
def set_aasm_current_state_with_persistence(state)
def aasm_set_current_state_with_persistence(state)
save_success = true
if self.respond_to?(:aasm_write_state) || self.private_methods.include?('aasm_write_state')
save_success = aasm_write_state(state)
@ -150,7 +150,7 @@ private
obj
end
def aasm_test_event(name, *args)
def aasm_may_fire_event?(name, *args)
event = self.class.aasm_events[name]
event.may_fire?(self, *args)
end
@ -179,7 +179,7 @@ private
persist_successful = true
if persist
persist_successful = set_aasm_current_state_with_persistence(new_state_name)
persist_successful = aasm_set_current_state_with_persistence(new_state_name)
event.execute_success_callback(self) if persist_successful
else
self.aasm_current_state = new_state_name

View file

@ -29,7 +29,7 @@ module AASM
# may_event? and get back a boolean that tells you whether the guard method
# on the transition will let this happen.
@clazz.send(:define_method, "may_#{name.to_s}?") do |*args|
aasm_test_event(name, *args)
aasm_may_fire_event?(name, *args)
end
@clazz.send(:define_method, "#{name.to_s}!") do |*args|
@ -52,5 +52,6 @@ module AASM
def states_for_select
states.map { |state| state.for_select }
end
end
end

View file

@ -7,7 +7,7 @@ class AASM::SupportingClasses::Event
update(options, &block)
end
# a neutered version of fire - it doesn't actually fir the event, it just
# a neutered version of fire - it doesn't actually fire the event, it just
# executes the transition guards to determine if a transition is even
# an option given current conditions.
def may_fire?(obj, to_state=nil)

View file

@ -274,7 +274,7 @@ describe AASM, '- event callbacks' do
end
it 'should not call it for failing bang fire' do
@foo.stub!(:set_aasm_current_state_with_persistence).and_return(false)
@foo.stub!(:aasm_set_current_state_with_persistence).and_return(false)
@foo.should_not_receive(:aasm_event_fired)
@foo.close!
end
@ -298,7 +298,7 @@ describe AASM, '- event callbacks' do
end
it 'should not call it if persist fails for bang fire' do
@foo.stub!(:set_aasm_current_state_with_persistence).and_return(false)
@foo.stub!(:aasm_set_current_state_with_persistence).and_return(false)
@foo.should_receive(:aasm_event_failed)
@foo.close!
end