Class: YARD::Delegate::Handler

Inherits:
Handlers::Ruby::Base
  • Object
show all
Defined in:
lib/yard-delegate/handler.rb

Instance Method Summary collapse

Instance Method Details

#delegate(*names) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/yard-delegate/handler.rb', line 9

def delegate(*names)
  hash = names.pop
  to   = hash[:to] || hash["to"]

  names.each do |name|
    register YARD::CodeObjects::MethodObject.new(namespace, name, scope) { |o|
      o.parameters = [["*args", nil], ["&block", nil]]
      o.source = "def #{name}(*args, &block)\n  #{to}.#{name}(*args, &block)\nend"
      o.signature = "def #{name}(*args, &block)"
      o.docstring = statement.comments.to_s.empty? ? "" : statement.comments
      o.delegate = to
    }
  end
end