Class: YARD::CodeObjects::ModuleObject

Inherits:
NamespaceObject show all
Defined in:
lib/yard/code_objects/module_object.rb

Overview

Represents a Ruby module.

Direct Known Subclasses

RootObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from YARD::CodeObjects::NamespaceObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class YARD::CodeObjects::Base

Instance Attribute Details

#aliasesHash (readonly) Originally defined in class NamespaceObject

A hash containing two keys, :class and :instance, each containing a hash of objects and their alias names.

Returns:

  • (Hash)

    a list of methods

#attributesHash (readonly) Originally defined in class NamespaceObject

A hash containing two keys, class and instance, each containing the attribute name with a { :read, :write } hash for the read and write objects respectively.

Examples:

The attributes of an object

>> Registry.at('YARD::Docstring').attributes
=> {
      :class => { },
      :instance => {
        :ref_tags => {
          :read => #<yardoc method YARD::Docstring#ref_tags>,
          :write => nil
        },
        :object => {
          :read => #<yardoc method YARD::Docstring#object>,
          :write => #<yardoc method YARD::Docstring#object=>
         },
         ...
      }
    }

Returns:

  • (Hash)

    a list of methods

#base_docstringDocstring (readonly) Originally defined in class Base

The non-localized documentation string associated with the object

Returns:

Since:

  • 0.8.4

#child(opts = {}) ⇒ Base? Originally defined in class NamespaceObject

Looks for a child that matches the attributes specified by opts.

Examples:

Finds a child by name and scope

namespace.child(:name => :to_s, :scope => :instance)
# => #<yardoc method MyClass#to_s>

Returns:

  • (Base, nil)

    the first matched child object, or nil

#childrenArray<Base> (readonly) Originally defined in class NamespaceObject

The list of objects defined in this namespace

Returns:

#class_attributesHash Originally defined in class NamespaceObject

Only the class attributes

Returns:

  • (Hash)

    a list of method names and their read/write objects

See Also:

#class_mixinsArray<ModuleObject> (readonly) Originally defined in class NamespaceObject

Class mixins

Returns:

#constants(opts = {}) ⇒ Array<ConstantObject> Originally defined in class NamespaceObject

Returns all constants in the namespace

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :included (Boolean) — default: true

    whether or not to include mixed in constants in list

Returns:

#cvarsArray<ClassVariableObject> Originally defined in class NamespaceObject

Returns class variables defined in this namespace.

Returns:

#dynamicBoolean Originally defined in class Base

Marks whether or not the method is conditionally defined at runtime

Returns:

  • (Boolean)

    true if the method is conditionally defined at runtime

#filesArray<String> (readonly) Originally defined in class Base

The files the object was defined in. To add a file, use #add_file.

Returns:

See Also:

#groupString Originally defined in class Base

Returns the group this object is associated with

Returns:

  • (String)

    the group this object is associated with

Since:

  • 0.6.0

#groupsArray<String> Originally defined in class NamespaceObject

Returns a list of ordered group names inside the namespace

Returns:

  • (Array<String>)

    a list of ordered group names inside the namespace

Since:

  • 0.6.0

#included_constantsArray<ConstantObject> Originally defined in class NamespaceObject

Returns constants included from any mixins

Returns:

#included_meths(opts = {}) ⇒ Object Originally defined in class NamespaceObject

Returns methods included from any mixins that match the attributes specified by opts. If no options are specified, returns all included methods.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :visibility (Array<Symbol>, Symbol) — default: [:public, :private, :protected]

    the visibility of the methods to list. Can be an array or single value.

  • :scope (Array<Symbol>, Symbol) — default: [:class, :instance]

    the scope of the methods to list. Can be an array or single value.

  • :included (Boolean) — default: true

    whether to include mixed in methods in the list.

See Also:

#instance_attributesHash Originally defined in class NamespaceObject

Only the instance attributes

Returns:

  • (Hash)

    a list of method names and their read/write objects

See Also:

#instance_mixinsArray<ModuleObject> (readonly) Originally defined in class NamespaceObject

Instance mixins

Returns:

#meths(opts = {}) ⇒ Array<MethodObject> Originally defined in class NamespaceObject

Returns all methods that match the attributes specified by opts. If no options are provided, returns all methods.

Examples:

Finds all private and protected class methods

namespace.meths(:visibility => [:private, :protected], :scope => :class)
# => [#<yardoc method MyClass.privmeth>, #<yardoc method MyClass.protmeth>]

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :visibility (Array<Symbol>, Symbol) — default: [:public, :private, :protected]

    the visibility of the methods to list. Can be an array or single value.

  • :scope (Array<Symbol>, Symbol) — default: [:class, :instance]

    the scope of the methods to list. Can be an array or single value.

  • :included (Boolean) — default: true

    whether to include mixed in methods in the list.

Returns:

#mixins(*scopes) ⇒ Array<ModuleObject> Originally defined in class NamespaceObject

Returns for specific scopes. If no scopes are provided, returns all mixins.

Parameters:

  • scopes (Array<Symbol>)

    a list of scopes (:class, :instance) to return mixins for. If this is empty, all scopes will be returned.

Returns:

#namespaceNamespaceObject Also known as: parent Originally defined in class Base

The namespace the object is defined in. If the object is in the top level namespace, this is Registry.root

Returns:

#signatureString Originally defined in class Base

The one line signature representing an object. For a method, this will be of the form “def meth(arguments…)”. This is usually the first source line.

Returns:

  • (String)

    a line of source

#sourceString? Originally defined in class Base

The source code associated with the object

Returns:

  • (String, nil)

    source, if present, or nil

#source_typeSymbol Originally defined in class Base

Language of the source code associated with the object. Defaults to :ruby.

Returns:

  • (Symbol)

    the language type

#visibilitySymbol Originally defined in class Base

Returns the visibility of an object (:public, :private, :protected)

Returns:

  • (Symbol)

    the visibility of an object (:public, :private, :protected)

Instance Method Details

#inheritance_tree(include_mods = false) ⇒ Array<NamespaceObject>

Returns the inheritance tree of mixins.

Parameters:

  • include_mods (Boolean) (defaults to: false)

    if true, will include mixed in modules (which is likely what is wanted).

Returns:



9
10
11
12
13
14
15
16
# File 'lib/yard/code_objects/module_object.rb', line 9

def inheritance_tree(include_mods = false)
  return [self] unless include_mods
  [self] + mixins(:instance, :class).map do |m|
    next if m == self
    next m unless m.respond_to?(:inheritance_tree)
    m.inheritance_tree(true)
  end.compact.flatten.uniq
end