Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: aad5a30bf2
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (35 sloc) 0.824 kB
module ActiveModel
module StateMachine
class StateTransition
attr_reader :from, :to, :options
def initialize(opts)
@from, @to, @guard, @on_transition = opts[:from], opts[:to], opts[:guard], opts[:on_transition]
@options = opts
end
def perform(obj)
case @guard
when Symbol, String
obj.send(@guard)
when Proc
@guard.call(obj)
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
def from?(value)
@from == value
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.