Sha256: 6314112cc84ca02c121d5612b0fb921849682822af701859fa1c1afa3bbf3715
Contents?: true
Size: 1.4 KB
Versions: 11
Compression:
Stored size: 1.4 KB
Contents
module EnumStateMachine module YARD module Handlers # Handles and processes #transition class Transition < Base handles method_call(:transition) def process if [EnumStateMachine::Machine, EnumStateMachine::Event, EnumStateMachine::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 # Extracts the statement requirement from the given node 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 end end end end
Version data entries
11 entries across 11 versions & 1 rubygems