Class: Mutator::Transition

Inherits:
Object
  • Object
show all
Defined in:
lib/mutator/transition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fromObject (readonly)

Returns the value of attribute from.



3
4
5
# File 'lib/mutator/transition.rb', line 3

def from
  @from
end

#machineObject (readonly)

Returns the value of attribute machine.



3
4
5
# File 'lib/mutator/transition.rb', line 3

def machine
  @machine
end

#toObject (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

#callObject



11
12
13
# File 'lib/mutator/transition.rb', line 11

def call
  stateholder.state = to if valid?
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/mutator/transition.rb', line 27

def eql? other
  public_send :==, other
end

#stateholderObject



19
20
21
# File 'lib/mutator/transition.rb', line 19

def stateholder
  machine.stateholder
end

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mutator/transition.rb', line 15

def valid?
  transitions.length > 0
end