Class: Mutator::Transition
- Inherits:
-
Object
- Object
- Mutator::Transition
- Defined in:
- lib/mutator/transition.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(opts) ⇒ Transition
constructor
A new instance of Transition.
- #stateholder ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(opts) ⇒ Transition
Returns a new instance of Transition.
5 6 7 8 9 |
# File 'lib/mutator/transition.rb', line 5 def initialize opts @to = opts.fetch(:to) @from = opts.fetch(:from) @machine = opts.fetch(:machine) end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
3 4 5 |
# File 'lib/mutator/transition.rb', line 3 def from @from end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
3 4 5 |
# File 'lib/mutator/transition.rb', line 3 def machine @machine end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
3 4 5 |
# File 'lib/mutator/transition.rb', line 3 def to @to end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/mutator/transition.rb', line 23 def == other to == other.to && from == other.from && machine == other.machine end |
#call ⇒ Object
11 12 13 |
# File 'lib/mutator/transition.rb', line 11 def call stateholder.state = to if valid? end |
#eql?(other) ⇒ Boolean
27 28 29 |
# File 'lib/mutator/transition.rb', line 27 def eql? other public_send :==, other end |
#stateholder ⇒ Object
19 20 21 |
# File 'lib/mutator/transition.rb', line 19 def stateholder machine.stateholder end |
#valid? ⇒ Boolean
15 16 17 |
# File 'lib/mutator/transition.rb', line 15 def valid? transitions.length > 0 end |