Class: StateMachine::YARD::Handlers::Transition

Inherits:
Base
  • Object
show all
Defined in:
lib/state_machine/yard/handlers/transition.rb

Overview

Handles and processes #transition

Instance Method Summary (collapse)

Instance Method Details

- (Object) process



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/state_machine/yard/handlers/transition.rb', line 8

def process
  if [StateMachine::Machine, StateMachine::Event, StateMachine::State].include?(owner.class)
    options = {}
    
    # Extract requirements
    ast = statement.parameters.first
    ast.children.each do |assoc|
      # Skip conditionals
      next if %w(if unless).include?(assoc[0].jump(:ident).source)
      
      options[extract_requirement(assoc[0])] = extract_requirement(assoc[1])
    end
    
    owner.transition(options)
  end
end