lib/state_transition.rb in rubyist-aasm-2.0.0 vs lib/state_transition.rb in rubyist-aasm-2.0.1

- old
+ new

@@ -2,11 +2,11 @@ module SupportingClasses class StateTransition attr_reader :from, :to, :opts def initialize(opts) - @from, @to, @guard = opts[:from], opts[:to], opts[:guard] + @from, @to, @guard, @on_transition = opts[:from], opts[:to], opts[:guard], opts[:on_transition] @opts = opts end def perform(obj) case @guard @@ -17,9 +17,18 @@ else true end end + def execute(obj, *args) + case @on_transition + when Symbol, String + obj.send(@on_transition, *args) + when Proc + @on_transition.call(obj, *args) + end + end + def ==(obj) @from == obj.from && @to == obj.to end end end