Sha256: 3aa86028ae702a21e02ef6e01aa3b7456fee829815cf71f8138d0d2627976416

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 Bytes

Contents

require 'yard'

module YARD
  module Handlers
    module Ruby
      class ParameterHandler < Base

        handles method_call(:parameter)

        def process
          obj = statement.parameters(false).first
          nobj = namespace
          mscope = scope
          name = case obj.type
                 when :symbol_literal
                   obj.jump(:ident, :op, :kw, :const).source
                 when :string_literal
                   obj.jump(:string_content).source
                 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

2 entries across 2 versions & 1 rubygems

Version Path
parameters-0.1.9 lib/parameters/yard/handlers/ruby/parameter_handler.rb
parameters-0.1.8 lib/parameters/yard/handlers/ruby/parameter_handler.rb