Sha256: d94f22171b58e2ab0145dd4470b178f9b47b325243e36b60cfd09a1556a16fc8

Contents?: true

Size: 918 Bytes

Versions: 2

Compression:

Stored size: 918 Bytes

Contents

require 'yard'

module YARD
  module Handlers
    module Ruby
      class PredefineHandler < 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 & 1 rubygems

Version Path
dm-predefined-0.2.1 lib/dm-predefined/yard/handlers/ruby/predefine_handler.rb
dm-predefined-0.2.0 lib/dm-predefined/yard/handlers/ruby/predefine_handler.rb