Sha256: c26021adb421e49ce61f4efd928ac97ebca1b12d688567de438bed7076d13ca3

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'yard'

require 'ronin/yard/handlers/ruby/base'

module YARD
  module Handlers
    module Ruby
      class BelongsToHandler < Base

        handles method_call(:belongs_to)

        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

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-0.3.0 lib/ronin/yard/handlers/ruby/belongs_to_handler.rb