Class: Mocha::StateMachine::State

Inherits:
Object
  • Object
show all
Defined in:
lib/mocha/state_machine.rb

Overview

Provides a mechanism to change the state of a Mocha::StateMachine at some point in the future.

Instance Method Summary collapse

Constructor Details

#initialize(state_machine, state) ⇒ State

Returns a new instance of State


11
12
13
# File 'lib/mocha/state_machine.rb', line 11

def initialize(state_machine, state)
  @state_machine, @state = state_machine, state
end

Instance Method Details

#activateObject


16
17
18
# File 'lib/mocha/state_machine.rb', line 16

def activate
  @state_machine.current_state = @state
end

#active?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/mocha/state_machine.rb', line 21

def active?
  @state_machine.current_state == @state
end

#mocha_inspectObject


26
27
28
# File 'lib/mocha/state_machine.rb', line 26

def mocha_inspect
  "#{@state_machine.name} is #{@state.mocha_inspect}"
end