Sha256: ccf4c72c6cc08d9257fa4c2ca38e7e667dba2bfd5f18f589a6effa73255d1637

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

module YARD
  module DM
    module Predefined
      class PredefineHandler < YARD::Handlers::Ruby::Base

        handles method_call(:predefine)

        def process
          nobj = namespace
          name = if statement.type == :predefine
                   statement.jump(:ident, :op, :kw, :const).source
                 elsif statement.call?
                   obj = statement.parameters(false).first

                   case obj.type
                   when :symbol_literal
                     obj.jump(:ident, :op, :kw, :const).source
                   when :string_literal
                     obj.jump(:string_content).source
                   end
                 end

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

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
yard-dm-is-predefined-0.2.0 lib/yard-dm-is-predefined/predefine_handler.rb
yard-dm-predefined-0.1.0 lib/yard-dm-predefined/predefine_handler.rb