Class: YARD::DM::BelongsToHandler

Inherits:
Handlers::Ruby::Base
  • Object
show all
Includes:
Extensions
Defined in:
lib/yard-dm/belongs_to_handler.rb

Instance Method Summary collapse

Methods included from Extensions

#effected_namespace

Instance Method Details

#processObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/yard-dm/belongs_to_handler.rb', line 11

def process
  nobj = effected_namespace
  mscope = scope
  name = statement.parameters[0].last

  if name.type == :symbol
    name = name.source[1..-1]

    register MethodObject.new(nobj, name, :class) do |o|
      o.visibility = :public
      o.source = statement.source
      o.signature = "def self.#{name}"
      o.parameters = [['repository', 'nil']]
    end

    register MethodObject.new(nobj, name, mscope) do |o|
      o.visibility = :public
      o.source = statement.source
      o.signature = "def #{name}"
    end

    register MethodObject.new(nobj, "#{name}=", mscope) do |o|
      o.visibility = :public
      o.source = statement.source
      o.signature = "def #{name}=(resource)"
      o.parameters = [['resource', nil]]
    end
  end
end