Class: YARD::CodeObjects::Proxy

### Home Classes Methods

### In Files

- lib/yard/code_objects/proxy.rb

### Parent

Object

### Methods

- ::===
- ::new
- #<=>
- #==
- #===
- #class
- #equal?
- #hash
- #inspect
- #instance_of?
- #is_a?
- #kind_of?
- #method_missing
- #name
- #path
- #respond_to?
- #root?
- #title
- #to_s
- #to_str
- #type
- #type=

### Files

- LICENSE.txt
- MIT.txt

### Class/Module Index

Quicksearch

- YARD
- YARD::CLI
- YARD::CLI::Command
- YARD::CLI::CommandParser
- YARD::CLI::Config
- YARD::CLI::Diff
- YARD::CLI::Display
- YARD::CLI::Gems
- YARD::CLI::Graph
- YARD::CLI::GraphOptions
- YARD::CLI::Help
- YARD::CLI::I18n
- YARD::CLI::List
- YARD::CLI::MarkupTypes
- YARD::CLI::Server
- YARD::CLI::Stats
- YARD::CLI::YRI
- YARD::CLI::Yardoc
- YARD::CLI::YardocOptions
- YARD::CLI::YardoptsCommand
- YARD::CodeObjects
- YARD::CodeObjects::Base
- YARD::CodeObjects::ClassObject
- YARD::CodeObjects::ClassVariableObject
- YARD::CodeObjects::CodeObjectList
- YARD::CodeObjects::ConstantObject
- YARD::CodeObjects::ExtendedMethodObject
- YARD::CodeObjects::ExtraFileObject
- YARD::CodeObjects::MacroObject
- YARD::CodeObjects::MethodObject
- YARD::CodeObjects::ModuleObject
- YARD::CodeObjects::NamespaceObject
- YARD::CodeObjects::Proxy
- YARD::CodeObjects::ProxyMethodError
- YARD::CodeObjects::RootObject
- YARD::Config
- YARD::Docstring
- YARD::DocstringParser
- YARD::Handlers
- YARD::Handlers::Base
- YARD::Handlers::C
- YARD::Handlers::C::AliasHandler
- YARD::Handlers::C::AttributeHandler
- YARD::Handlers::C::Base
- YARD::Handlers::C::ClassHandler
- YARD::Handlers::C::ConstantHandler
- YARD::Handlers::C::HandlerMethods
- YARD::Handlers::C::InitHandler
- YARD::Handlers::C::MethodHandler
- YARD::Handlers::C::MixinHandler
- YARD::Handlers::C::ModuleHandler
- YARD::Handlers::C::OverrideCommentHandler
- YARD::Handlers::C::PathHandler
- YARD::Handlers::C::StructHandler
- YARD::Handlers::C::SymbolHandler
- YARD::Handlers::HandlerAborted
- YARD::Handlers::NamespaceMissingError
- YARD::Handlers::Processor
- YARD::Handlers::Ruby
- YARD::Handlers::Ruby::AliasHandler
- YARD::Handlers::Ruby::AttributeHandler
- YARD::Handlers::Ruby::Base
- YARD::Handlers::Ruby::ClassConditionHandler
- YARD::Handlers::Ruby::ClassHandler
- YARD::Handlers::Ruby::ClassVariableHandler
- YARD::Handlers::Ruby::CommentHandler
- YARD::Handlers::Ruby::ConstantHandler
- YARD::Handlers::Ruby::DSLHandler
- YARD::Handlers::Ruby::DSLHandlerMethods
- YARD::Handlers::Ruby::ExceptionHandler
- YARD::Handlers::Ruby::ExtendHandler
- YARD::Handlers::Ruby::HandlesExtension
- YARD::Handlers::Ruby::Legacy
- YARD::Handlers::Ruby::Legacy::AliasHandler
- YARD::Handlers::Ruby::Legacy::AttributeHandler
- YARD::Handlers::Ruby::Legacy::Base
- YARD::Handlers::Ruby::Legacy::ClassConditionHandler
- YARD::Handlers::Ruby::Legacy::ClassHandler
- YARD::Handlers::Ruby::Legacy::ClassVariableHandler
- YARD::Handlers::Ruby::Legacy::CommentHandler
- YARD::Handlers::Ruby::Legacy::ConstantHandler
- YARD::Handlers::Ruby::Legacy::DSLHandler
- YARD::Handlers::Ruby::Legacy::ExceptionHandler
- YARD::Handlers::Ruby::Legacy::ExtendHandler
- YARD::Handlers::Ruby::Legacy::MethodHandler
- YARD::Handlers::Ruby::Legacy::MixinHandler
- YARD::Handlers::Ruby::Legacy::ModuleFunctionHandler
- YARD::Handlers::Ruby::Legacy::ModuleHandler
- YARD::Handlers::Ruby::Legacy::PrivateClassMethodHandler
- YARD::Handlers::Ruby::Legacy::PrivateConstantHandler
- YARD::Handlers::Ruby::Legacy::VisibilityHandler
- YARD::Handlers::Ruby::Legacy::YieldHandler
- YARD::Handlers::Ruby::MethodCallWrapper
- YARD::Handlers::Ruby::MethodConditionHandler
- YARD::Handlers::Ruby::MethodHandler
- YARD::Handlers::Ruby::MixinHandler
- YARD::Handlers::Ruby::ModuleFunctionHandler
- YARD::Handlers::Ruby::ModuleHandler
- YARD::Handlers::Ruby::PrivateClassMethodHandler
- YARD::Handlers::Ruby::PrivateConstantHandler
- YARD::Handlers::Ruby::StructHandlerMethods
- YARD::Handlers::Ruby::TestNodeWrapper
- YARD::Handlers::Ruby::VisibilityHandler
- YARD::Handlers::Ruby::YieldHandler
- YARD::I18n
- YARD::I18n::Locale
- YARD::I18n::Message
- YARD::I18n::Messages
- YARD::I18n::POParser
- YARD::I18n::PotGenerator
- YARD::I18n::Text
- YARD::Logger
- YARD::Options
- YARD::Parser
- YARD::Parser::Base
- YARD::Parser::C
- YARD::Parser::C::BodyStatement
- YARD::Parser::C::CParser
- YARD::Parser::C::Comment
- YARD::Parser::C::CommentParser
- YARD::Parser::C::Statement
- YARD::Parser::C::ToplevelStatement
- YARD::Parser::OrderedParser
- YARD::Parser::ParserSyntaxError
- YARD::Parser::Ruby
- YARD::Parser::Ruby::AstNode
- YARD::Parser::Ruby::ClassNode
- YARD::Parser::Ruby::CommentNode
- YARD::Parser::Ruby::ConditionalNode
- YARD::Parser::Ruby::KeywordNode
- YARD::Parser::Ruby::Legacy
- YARD::Parser::Ruby::Legacy::RubyLex
- YARD::Parser::Ruby::Legacy::RubyLex::BufferedReader
- YARD::Parser::Ruby::Legacy::RubyParser
- YARD::Parser::Ruby::Legacy::RubyToken
- YARD::Parser::Ruby::Legacy::RubyToken::TkBlockContents
- YARD::Parser::Ruby::Legacy::RubyToken::TkError
- YARD::Parser::Ruby::Legacy::RubyToken::TkId
- YARD::Parser::Ruby::Legacy::RubyToken::TkKW
- YARD::Parser::Ruby::Legacy::RubyToken::TkNode
- YARD::Parser::Ruby::Legacy::RubyToken::TkOPASGN
- YARD::Parser::Ruby::Legacy::RubyToken::TkOp
- YARD::Parser::Ruby::Legacy::RubyToken::TkStatementEnd
- YARD::Parser::Ruby::Legacy::RubyToken::TkUnknownChar
- YARD::Parser::Ruby::Legacy::RubyToken::TkVal
- YARD::Parser::Ruby::Legacy::RubyToken::TkWhitespace
- YARD::Parser::Ruby::Legacy::RubyToken::Token
- YARD::Parser::Ruby::Legacy::Statement
- YARD::Parser::Ruby::Legacy::StatementList
- YARD::Parser::Ruby::Legacy::TokenList
- YARD::Parser::Ruby::LiteralNode
- YARD::Parser::Ruby::LoopNode
- YARD::Parser::Ruby::MethodCallNode
- YARD::Parser::Ruby::MethodDefinitionNode
- YARD::Parser::Ruby::ModuleNode
- YARD::Parser::Ruby::ParameterNode
- YARD::Parser::Ruby::ReferenceNode
- YARD::Parser::Ruby::RipperParser
- YARD::Parser::Ruby::RubyParser
- YARD::Parser::SourceParser
- YARD::Parser::UndocumentableError
- YARD::Rake
- YARD::Rake::YardocTask
- YARD::Registry
- YARD::RegistryStore
- YARD::Serializers
- YARD::Serializers::Base
- YARD::Serializers::FileSystemSerializer
- YARD::Serializers::ProcessSerializer
- YARD::Serializers::StdoutSerializer
- YARD::Serializers::YardocSerializer
- YARD::Server
- YARD::Server::Adapter
- YARD::Server::Commands
- YARD::Server::Commands::Base
- YARD::Server::Commands::DisplayFileCommand
- YARD::Server::Commands::DisplayObjectCommand
- YARD::Server::Commands::FramesCommand
- YARD::Server::Commands::LibraryCommand
- YARD::Server::Commands::LibraryIndexCommand
- YARD::Server::Commands::LibraryOptions
- YARD::Server::Commands::ListCommand
- YARD::Server::Commands::SearchCommand
- YARD::Server::Commands::StaticFileCommand
- YARD::Server::DocServerHelper
- YARD::Server::DocServerSerializer
- YARD::Server::FinishRequest
- YARD::Server::LibraryNotPreparedError
- YARD::Server::LibraryVersion
- YARD::Server::NotFoundError
- YARD::Server::RackAdapter
- YARD::Server::RackMiddleware
- YARD::Server::Router
- YARD::Server::StaticCaching
- YARD::Server::WebrickAdapter
- YARD::Server::WebrickServlet
- YARD::StubProxy
- YARD::Tags
- YARD::Tags::AttributeDirective
- YARD::Tags::DefaultFactory
- YARD::Tags::DefaultTag
- YARD::Tags::Directive
- YARD::Tags::EndGroupDirective
- YARD::Tags::GroupDirective
- YARD::Tags::Library
- YARD::Tags::MacroDirective
- YARD::Tags::MethodDirective
- YARD::Tags::OptionTag
- YARD::Tags::OverloadTag
- YARD::Tags::ParseDirective
- YARD::Tags::RefTag
- YARD::Tags::RefTagList
- YARD::Tags::ScopeDirective
- YARD::Tags::Tag
- YARD::Tags::TagFormatError
- YARD::Tags::VisibilityDirective
- YARD::Templates
- YARD::Templates::Engine
- YARD::Templates::ErbCache
- YARD::Templates::Helpers
- YARD::Templates::Helpers::BaseHelper
- YARD::Templates::Helpers::FilterHelper
- YARD::Templates::Helpers::HtmlHelper
- YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
- YARD::Templates::Helpers::Markup
- YARD::Templates::Helpers::Markup::RDocMarkdown
- YARD::Templates::Helpers::Markup::RDocMarkup
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkup
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkup::RDocMarkupToHtml
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkupToHtml
- YARD::Templates::Helpers::MarkupHelper
- YARD::Templates::Helpers::MethodHelper
- YARD::Templates::Helpers::ModuleHelper
- YARD::Templates::Helpers::TextHelper
- YARD::Templates::Helpers::UMLHelper
- YARD::Templates::Section
- YARD::Templates::Template
- YARD::Templates::Template::ClassMethods
- YARD::Templates::TemplateOptions
- YARD::Verifier
- Gem
- Gem::DocManager
- Gem::SourceIndex
- Gem::Specification
- Rack
- Rack::Request
- WEBrick
- WEBrick::HTTPRequest
- Array
- File
- Hash
- Insertion
- Module
- Object
- String
- SymbolHash

No matching classes.

# YARD::CodeObjects::Proxy

The Proxy class is a way to lazily resolve code objects in cases where the object may not yet exist. A proxy simply stores an unresolved path until a method is called on the object, at which point it does a lookup using {Registry.resolve}. If the object is not found, a warning is raised and {ProxyMethodError} might be raised.

@example Creates a Proxy to the String class from a module

    # When the String class is parsed this method will
    # begin to act like the String ClassObject.
    Proxy.new(mymoduleobj, "String")

@see Registry.resolve @see ProxyMethodError

### Attributes

namespace[R]
parent[R]

### Public Class Methods

===(other) click to toggle source

    # File lib/yard/code_objects/proxy.rb, line 19
    def self.===(other) other.is_a?(self) end

new(namespace, name, type = nil) click to toggle source

Creates a new Proxy

@raise [ArgumentError] if namespace is not a NamespaceObject @return [Proxy] self

    # File lib/yard/code_objects/proxy.rb, line 28
    def initialize(namespace, name, type = nil)
      namespace = Registry.root if !namespace || namespace == :root

      if name =~ /^#{NSEPQ}/
        namespace = Registry.root
        name = name[2..-1]
      end

      if name =~ /(?:#{NSEPQ}|#{ISEPQ}|#{CSEPQ})([^#{NSEPQ}#{ISEPQ}#{CSEPQ}]+)$/
        @orignamespace, @origname = namespace, name
        @imethod = true if name.include? ISEP
        namespace = Proxy.new(namespace, $`) unless $`.empty?
        name = $1
      else
        @orignamespace, @origname, @imethod = nil, nil, nil
      end

      @name = name.to_sym
      @namespace = namespace
      @obj = nil
      @imethod ||= nil
      self.type = type

      if @namespace.is_a?(ConstantObject)
        @origname = nil # forget these for a constant
        @orignamespace = nil
        @namespace = Proxy.new(@namespace.namespace, @namespace.value)
      end

      unless @namespace.is_a?(NamespaceObject) or @namespace.is_a?(Proxy)
        raise ArgumentError, "Invalid namespace object: #{namespace}"
      end

      # If the name begins with "::" (like "::String")
      # this is definitely a root level object, so
      # remove the namespace and attach it to the root
      if @name =~ /^#{NSEPQ}/
        @name.gsub!(/^#{NSEPQ}/, '')
        @namespace = Registry.root
      end
    end

### Public Instance Methods

<=>(other) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 120
    def <=>(other)
      if other.respond_to? :path
        path <=> other.path
      else
        false
      end
    end

==(other) click to toggle source
Alias for: equal?
===(other) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 111
    def ===(other)
      if obj = to_obj
        obj === other
      else
        self.class <= other.class
      end
    end

class() click to toggle source

Returns the class name of the object the proxy is mimicking, if resolved. Otherwise returns `Proxy`. @return [Class] the resolved object's class or `Proxy`

    # File lib/yard/code_objects/proxy.rb, line 144
    def class
      if obj = to_obj
        obj.class
      else
        Proxy
      end
    end

equal?(other) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 129
    def equal?(other)
      if other.respond_to? :path
        path == other.path
      else
        false
      end
    end

Also aliased as: ==
hash() click to toggle source

@return [Integer] the object's hash value (for equality checking)

    # File lib/yard/code_objects/proxy.rb, line 139
    def hash; path.hash end

inspect() click to toggle source

Returns a text representation of the Proxy @return [String] the object's inspect method or P(OBJECTPATH)

    # File lib/yard/code_objects/proxy.rb, line 77
    def inspect
      if obj = to_obj
        obj.inspect
      else
        "P(#{path})"
      end
    end

instance_of?(klass) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 171
    def instance_of?(klass)
      self.class == klass
    end

is_a?(klass) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 102
    def is_a?(klass)
      if obj = to_obj
        obj.is_a?(klass)
      else
        self.class <= klass
      end
    end

kind_of?(klass) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 176
    def kind_of?(klass)
      self.class <= klass
    end

method_missing(meth, *args, &block) click to toggle source

Dispatches the method to the resolved object.

@raise [ProxyMethodError] if the proxy cannot find the real object

    # File lib/yard/code_objects/proxy.rb, line 192
    def method_missing(meth, *args, &block)
      if obj = to_obj
        obj.__send__(meth, *args, &block)
      else
        log.warn "Load Order / Name Resolution Problem on #{path}:"
        log.warn "-"
        log.warn "Something is trying to call #{meth} on object #{path} before it has been recognized."
        log.warn "This error usually means that you need to modify the order in which you parse files"
        log.warn "so that #{path} is parsed before methods or other objects attempt to access it."
        log.warn "-"
        log.warn "YARD will recover from this error and continue to parse but you *may* have problems"
        log.warn "with your generated documentation. You should probably fix this."
        log.warn "-"
        begin
          super
        rescue NoMethodError
          raise ProxyMethodError, "Proxy cannot call method ##{meth} on object '#{path}'"
        end
      end
    end

name(prefix = false) click to toggle source

(see Base#name)

    # File lib/yard/code_objects/proxy.rb, line 71
    def name(prefix = false)
      prefix ? (@imethod ? ISEP : '') + @name.to_s : @name
    end

path() click to toggle source

If the proxy resolves to an object, returns its path, otherwise guesses at the correct path using the original namespace and name.

@return [String] the assumed path of the proxy (or the real path

    of the resolved object)

    # File lib/yard/code_objects/proxy.rb, line 90
    def path
      if obj = to_obj
        obj.path
      else
        proxy_path
      end
    end

Also aliased as: to_s, to_str, title
respond_to?(meth, include_private = false) click to toggle source

@return [Boolean]

    # File lib/yard/code_objects/proxy.rb, line 181
    def respond_to?(meth, include_private = false)
      if obj = to_obj
        obj.respond_to?(meth, include_private)
      else
        super
      end
    end

root?() click to toggle source

This class is never a root object

    # File lib/yard/code_objects/proxy.rb, line 214
    def root?; false end

title() click to toggle source
Alias for: path
to_s() click to toggle source
Alias for: path
to_str() click to toggle source
Alias for: path
type() click to toggle source

Returns the type of the proxy. If it cannot be resolved at the time of the call, it will either return the inferred proxy type (see {type=}) or `:proxy` @return [Symbol] the Proxy's type @see type=

    # File lib/yard/code_objects/proxy.rb, line 157
    def type
      if obj = to_obj
        obj.type
      else
        @type || :proxy
      end
    end

type=(type) click to toggle source

Allows a parser to infer the type of the proxy by its path. @param [to_sym] type the proxy's inferred type @return [void]

    # File lib/yard/code_objects/proxy.rb, line 168
    def type=(type) @type = type ? type.to_sym : nil end

[Validate]

Generated with the Darkfish Rdoc Generator 2.