class StateMachine::YARD::Handlers::Transition
Handles and processes transition
Public Instance Methods
process()
click to toggle source
# 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
Private Instance Methods
extract_requirement(ast)
click to toggle source
Extracts the statement requirement from the given node
# File lib/state_machine/yard/handlers/transition.rb, line 27 def extract_requirement(ast) case ast.type when :symbol_literal, :string_literal, :array extract_node_names(ast, false) when :binary AllMatcher.instance - extract_node_names(ast.children.last) when :var_ref, :vcall case ast.source when 'nil' nil when 'same' LoopbackMatcher.instance else AllMatcher.instance end end end