lib/aasm/aasm.rb in aasm-4.1.0 vs lib/aasm/aasm.rb in aasm-4.1.1
- old
+ new
@@ -67,12 +67,14 @@
self,
*process_args(event, aasm.current_state, *args)
)
if may_fire_to = event.may_fire?(self, *args)
- old_state.fire_callbacks(:before_exit, self)
- old_state.fire_callbacks(:exit, self) # TODO: remove for AASM 4?
+ old_state.fire_callbacks(:before_exit, self,
+ *process_args(event, aasm.current_state, *args))
+ old_state.fire_callbacks(:exit, self,
+ *process_args(event, aasm.current_state, *args)) # TODO: remove for AASM 4?
if new_state_name = event.fire(self, {:may_fire => may_fire_to}, *args)
aasm_fired(event, old_state, new_state_name, options, *args, &block)
else
aasm_failed(event_name, old_state)
@@ -88,13 +90,15 @@
def aasm_fired(event, old_state, new_state_name, options, *args)
persist = options[:persist]
new_state = aasm.state_object_for_name(new_state_name)
- new_state.fire_callbacks(:before_enter, self)
+ new_state.fire_callbacks(:before_enter, self,
+ *process_args(event, aasm.current_state, *args))
- new_state.fire_callbacks(:enter, self) # TODO: remove for AASM 4?
+ new_state.fire_callbacks(:enter, self,
+ *process_args(event, aasm.current_state, *args)) # TODO: remove for AASM 4?
persist_successful = true
if persist
persist_successful = aasm.set_current_state_with_persistence(new_state_name)
if persist_successful
@@ -105,12 +109,14 @@
aasm.current_state = new_state_name
yield if block_given?
end
if persist_successful
- old_state.fire_callbacks(:after_exit, self)
- new_state.fire_callbacks(:after_enter, self)
+ old_state.fire_callbacks(:after_exit, self,
+ *process_args(event, aasm.current_state, *args))
+ new_state.fire_callbacks(:after_enter, self,
+ *process_args(event, aasm.current_state, *args))
event.fire_callbacks(
:after,
self,
*process_args(event, old_state.name, *args)
)
@@ -127,10 +133,10 @@
if self.respond_to?(:aasm_event_failed)
self.aasm_event_failed(event_name, old_state.name)
end
if AASM::StateMachine[self.class].config.whiny_transitions
- raise AASM::InvalidTransition, "Event '#{event_name}' cannot transition from '#{aasm.current_state}'"
+ raise AASM::InvalidTransition.new(self, event_name)
else
false
end
end