Class: Mocha::StateMachine
- Inherits:
- 
      Object
      
        - Object
- Mocha::StateMachine
 
- Defined in:
- lib/mocha/state_machine.rb
Overview
Defined Under Namespace
Classes: State, StatePredicate
Instance Method Summary collapse
- 
  
    
      #become(next_state_name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Put the StateMachine into the next_state_name.
- 
  
    
      #is(state_name)  ⇒ StatePredicate, State 
    
    
  
  
  
  
  
  
  
  
  
    Provides mechanisms to (a) determine whether the StateMachine is in a given state; or (b) to change the StateMachine into the given state. 
- 
  
    
      #is_not(unexpected_state_name)  ⇒ StatePredicate 
    
    
  
  
  
  
  
  
  
  
  
    Provides a mechanism to determine whether the StateMachine is not in the state specified by unexpected_state_nameat some point in the future.
- 
  
    
      #starts_as(initial_state_name)  ⇒ StateMachine 
    
    
  
  
  
  
  
  
  
  
  
    Put the StateMachine into the state specified by initial_state_name.
Instance Method Details
#become(next_state_name) ⇒ Object
Put the Mocha::StateMachine into the next_state_name.
| 58 59 60 | # File 'lib/mocha/state_machine.rb', line 58 def become(next_state_name) @current_state = next_state_name end | 
#is(expected_state_name) ⇒ StatePredicate #is(desired_state_name) ⇒ State
Provides mechanisms to (a) determine whether the Mocha::StateMachine is in a given state; or (b) to change the Mocha::StateMachine into the given state.
| 76 77 78 | # File 'lib/mocha/state_machine.rb', line 76 def is(state_name) State.new(self, state_name, 'is') { |current, given| current == given } end | 
#is_not(unexpected_state_name) ⇒ StatePredicate
Provides a mechanism to determine whether the Mocha::StateMachine is not in the state specified by unexpected_state_name at some point in the future.
| 84 85 86 | # File 'lib/mocha/state_machine.rb', line 84 def is_not(unexpected_state_name) # rubocop:disable Naming/PredicateName StatePredicate.new(self, unexpected_state_name, 'is not') { |current, given| current != given } end | 
#starts_as(initial_state_name) ⇒ StateMachine
Put the Mocha::StateMachine into the state specified by initial_state_name.
| 50 51 52 53 | # File 'lib/mocha/state_machine.rb', line 50 def starts_as(initial_state_name) become(initial_state_name) self end |