Skip to content

Qualify the namespace for Integrations - #2

Closed
olleolleolle wants to merge 1 commit into
state-machines:masterfrom
olleolleolle:patch-1
Closed

Qualify the namespace for Integrations#2
olleolleolle wants to merge 1 commit into
state-machines:masterfrom
olleolleolle:patch-1

Conversation

@olleolleolle

Copy link
Copy Markdown
Contributor

To get this working, I had to:

  • introduce a --load option to pre-load the code (perhaps this is ready to go into the README?)
  • add this PR's StateMachines:: namespacing of one line of code in the machine handler

# .yardopts
--load load_yard_plugins.rb
lib/**/*.rb
app/**/*.rb -
# load_yard_plugins.rb
require 'state_machines'
require 'state_machines/graphviz'
require 'state_machines/yard'

@olleolleolle

Copy link
Copy Markdown
Contributor Author

Closing, in favor of #1.

@olleolleolle

Copy link
Copy Markdown
Contributor Author

My current load_yard_plugins.rb:

require 'state_machines'
require 'state_machines/graphviz'
require 'state_machines/yard'

#
# See: https://github.com/state-machines/state_machines-yard/pull/1
#
class StateMachine::YARD::Handlers::Transition
  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
end

class StateMachine::YARD::Handlers::Machine
  def integration
    @integration ||= StateMachines::Integrations.match_ancestors(namespace.inheritance_tree(true).map { |ancestor| ancestor.path })
  end
end

@olleolleolle
olleolleolle deleted the patch-1 branch October 24, 2016 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant