Class | YARD::CodeObjects::MethodObject
In: | lib/yard/code_objects/method_object.rb
Parent: | Base

Represents a Ruby method in source

### Methods

aliases attr_info constructor? copyable_attributes is_alias? is_attribute? is_explicit? module_function? name new overridden_method path reader? scope= sep writer?

### Attributes

explicit | [RW] | Whether the object is explicitly defined in source or whether it was inferred by a handler. For instance, attribute methods are generally inferred and therefore not explicitly defined in source. @return [Boolean] whether the object is explicitly defined in source.

parameters

[RW]

Returns the list of parameters parsed out of the method signature with their default values.

@return [Array<Array(String, String)>] a list of parameter names followed

      by their default values (or nil)

scope | [R] | The scope of the method (+:class+ or +:instance+) @return [Symbol] the scope

### Public Class methods

new(namespace, name, scope = :instance, &block)

Creates a new method object in `namespace` with `name` and an instance or class `scope`

If scope is +:module+, this object is instantiated as a public method in +:class+ scope, but also creates a new (empty) method as a private +:instance+ method on the same class or module.

@param [NamespaceObject] namespace the namespace @param [String, Symbol] name the method name @param [Symbol] scope +:instance+, +:class+, or +:module+

### Public Instance methods

aliases()

Returns all alias names of the object @return [Array<Symbol>] the alias names

attr_info()

Returns the read/writer info for the attribute if it is one @return [SymbolHash] if there is information about the attribute @return [nil] if the method is not an attribute @since 0.5.3

constructor?()

@return whether or not the method is the initialize constructor method

is_alias?()

Tests if the object is defined as an alias of another method @return [Boolean] whether the object is an alias

is_attribute?()

Tests if the object is defined as an attribute in the namespace @return [Boolean] whether the object is an attribute

is_explicit?()

Tests boolean {explicit} value.

@return [Boolean] whether the method is explicitly defined in source

module_function?()

@return [Boolean] whether or not this method was created as a module

      function

@since 0.8.0

name(prefix = false)

Returns the name of the object.

@example The name of an instance method (with prefix)

      an_instance_method.name(true) # => "#mymethod"

@example The name of a class method (with prefix)

      a_class_method.name(true) # => "mymethod"

@param [Boolean] prefix whether or not to show the prefix @return [String] returns {sep} + `name` for an instance method if

      prefix is true

@return [Symbol] the name without {sep} if prefix is set to false

overridden_method()

@return [MethodObject] the object that this method overrides @return [nil] if it does not override a method @since 0.6.0

path()

Override path handling for instance methods in the root namespace (they should still have a separator as a prefix). @return [String] the path of a method

reader?()

@return [Boolean] whether the method is a reader attribute @since 0.5.3

scope=(v)

Changes the scope of an object from :instance or :class @param [Symbol] v the new scope

sep()

Override separator to differentiate between class and instance methods. @return [String] "#" for an instance method, "." for class

writer?()

@return [Boolean] whether the method is a writer attribute @since 0.5.3

### Protected Instance methods

copyable_attributes()

[Validate]