Class: StateMachines::YARD::Handlers::Transition

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

Overview

Handles and processes #transition

Instance Method Summary collapse

Instance Method Details

#processObject


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

def process
  if [StateMachines::Machine, StateMachines::Event, StateMachines::State].include?(owner.class)
    options = {}

    # Extract requirements
    ast = statement.parameters.first
    ast.children.each do |assoc|
      # Skip conditionals
      next if %w(if :if unless :unless).include?(assoc[0].jump(:ident).source)

      options[extract_requirement(assoc[0])] = extract_requirement(assoc[1])
    end

    owner.transition(options)
  end
end