Sha256: 3b4b4593e2209741b73f8fd6657fb257e3a465be4f174189bf2f8ca1e2e70574

Contents?: true

Size: 788 Bytes

Versions: 2

Compression:

Stored size: 788 Bytes

Contents

# Handles the 'include' statement to mixin a module in the instance scope
class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
  namespace_only
  handles method_call(:include)
  
  process do
    statement.parameters(false).each {|mixin| process_mixin(mixin) }
  end

  protected

  def process_mixin(mixin)
    unless mixin.ref?
      raise YARD::Parser::UndocumentableError, "mixin #{mixin.source} for class #{namespace.path}"
    end
    
    case obj = Proxy.new(namespace, mixin.source)
    when Proxy
      obj.type = :module
    when ConstantObject # If a constant is included, use its value as the real object
      obj = Proxy.new(namespace, obj.value)
    end
    
    namespace.mixins(scope).unshift(obj) unless namespace.mixins(scope).include?(obj)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yard-0.6.1 lib/yard/handlers/ruby/mixin_handler.rb
yard-0.6.0 lib/yard/handlers/ruby/mixin_handler.rb