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

refactoring: simplify Event initialization

This commit is contained in:
Vladimir Meremyanin 2013-03-06 13:45:26 +04:00
parent c3df420baa
commit 2c69f387fd

View file

@ -6,7 +6,8 @@ module AASM
def initialize(name, options = {}, &block)
@name = name
@transitions = []
update(options, &block)
@options = options
instance_eval(&block) if block
end
# a neutered version of fire - it doesn't actually fire the event, it just
@ -55,15 +56,6 @@ module AASM
end
private
def update(options = {}, &block)
@options = options
if block then
instance_eval(&block)
end
self
end
# Execute if test? == false, otherwise return true/false depending on whether it would fire
def _fire(obj, test, to_state=nil, *args)
if @transitions.map(&:from).any?