Sha256: 84cbe2872214a7dacd0ac5c7cab0fe6510a772da2fa1b649658579f7cd2ee3bf

Contents?: true

Size: 782 Bytes

Versions: 3

Compression:

Stored size: 782 Bytes

Contents

require 'yard'

module YARD
  module Handlers
    module Ruby
      class ContextifyHandler < Base

        handles method_call(:contextify)

        def process
          nobj = ModuleObject.new(:root, 'Kernel')
          obj = statement.parameters(false).first

          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}(&block)"
            o.parameters = [['&block', nil]]
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contextify-0.1.5 lib/contextify/yard/handlers/ruby/contextify_handler.rb
contextify-0.1.4 lib/contextify/yard/handlers/ruby/contextify_handler.rb
contextify-0.1.3 lib/contextify/yard/handlers/ruby/contextify_handler.rb