Sha256: 8767bb4dfc5009cd2e7e75de14c8de21e70f7a638936caa96922a45ee93f5069

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

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

      handles method_call(:parameter)

      def process
        nobj = namespace
        mscope = scope
        name = statement.parameters[0].first

        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 #{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/parameter_handler.rb