Class | YARD::CodeObjects::Proxy
In: | lib/yard/code_objects/proxy.rb
Parent: | Object

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

### Methods

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

### External Aliases

namespace | -> | parent

### Attributes

namespace | [R] |

### Public Class methods

===(other)
new(namespace, name, type = nil)

Creates a new Proxy

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

### Public Instance methods

<=>(other)

@return [Boolean]

==(other)

Alias for equal?

===(other)

@return [Boolean]

class()

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`

equal?(other)

@return [Boolean]

hash()

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

inspect()

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

instance_of?(klass)

@return [Boolean]

is_a?(klass)

@return [Boolean]

kind_of?(klass)

@return [Boolean]

method_missing(meth, *args, &block)

Dispatches the method to the resolved object.

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

name(prefix = false)

(see Base#name)

path()

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)

respond_to?(meth, include_private = false)

@return [Boolean]

root?()

This class is never a root object

to_s()

Alias for path

to_str()

Alias for path

type()

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=

type=(type)

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

[Validate]