Class: SwaggerYard::Handlers::DSLHandler

Inherits:
YARD::Handlers::Ruby::Base
  • Object
show all
Includes:
YARD::CodeObjects
Defined in:
lib/swagger_yard/handlers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.method_optionsObject



6
7
8
# File 'lib/swagger_yard/handlers.rb', line 6

def self.method_options
  @method_options ||= {}
end

.register_dsl_method(name, options = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/swagger_yard/handlers.rb', line 18

def self.register_dsl_method(name, options = {})
  return if self.method_options[name.to_s]
  options[:args] ||= 0..-1
  self.method_options[name.to_s] = options
  handles method_call(name)
end

.resetObject



10
11
12
13
14
15
16
# File 'lib/swagger_yard/handlers.rb', line 10

def self.reset
  method_options.keys.each do |m|
    handler = handlers.detect { |h| h.respond_to?(:name) && h.send(:name).to_s == m.to_s }
    handlers.delete handler if handler
  end
  method_options.clear
end

Instance Method Details

#processObject



25
26
27
28
29
30
31
32
33
# File 'lib/swagger_yard/handlers.rb', line 25

def process
  options = self.class.method_options[caller_method]
  return unless options
  call_params[options[:args]].each do |method_name|
    object = MethodObject.new(namespace, method_name, scope)
    object.signature = "def #{method_name}"
    register(object)
  end
end