Sha256: e3079540bcbcd0b69b1318a85dbee6e217e3771051e4f81102c58822a734a288

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module YARD
  module Parameters
    module Legacy
      class ParameterHandler < YARD::Handlers::Ruby::Legacy::Base

        handles /\Aparameter\s+:/

        def process
          nobj = namespace
          mscope = scope
          name = statement.tokens[2,1].to_s[1..-1]

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

          register MethodObject.new(nobj, "#{name}=", :class) do |o|
            o.visibility = :public
            o.source = statement.source
            o.signature = "def #{nobj}.#{name}=(value)"
            o.parameters = [['value', 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}=(value)"
            o.parameters = [['value', nil]]
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yard-parameters-0.1.1 lib/yard-parameters/legacy/parameter_handler.rb