Class: RDoc::Mixin (Ruby 2.3.2)
Description: Class : RDoc::Mixin - Ruby 2.3.2

- Home
- Core 2.3.2
- Std-lib 2.3.2
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- rdoc/mixin.rb

### Parent

RDoc::CodeObject

### Methods

- ::new
- #<=>
- #full_name
- #module
- #store=

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::POT
- RDoc::Generator::POT::MessageExtractor
- RDoc::Generator::POT::PO
- RDoc::Generator::POT::POEntry
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::I18n
- RDoc::I18n::Locale
- RDoc::I18n::Text
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::FormatterTestCase
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::Rule
- RDoc::Markup::Special
- RDoc::Markup::TextFormatterTestCase
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::RI::Task
- RDoc::Require
- RDoc::RubyLex
- RDoc::RubyLex::Error
- RDoc::RubyToken
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::TestCase
- RDoc::Text
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- RDocTask
- Test

No matching classes.

# RDoc::Mixin

A Mixin adds features from a module into another context. RDoc::Include and RDoc::Extend are both mixins.

### Attributes

name[RW]

Name of included module

### Public Class Methods

new(name, comment) click to toggle source

Creates a new Mixin for `name` with `comment`

                   # File rdoc/mixin.rb, line 15
    def initialize(name, comment)
      super()
      @name = name
      self.comment = comment
      @module = nil # cache for module if found
    end

### Public Instance Methods

<=>(other) click to toggle source

Mixins are sorted by name

                   # File rdoc/mixin.rb, line 25
    def <=> other
      return unless self.class === other

      name <=> other.name
    end

full_name() click to toggle source

Full name based on module

                   # File rdoc/mixin.rb, line 40
    def full_name
      m = self.module
      RDoc::ClassModule === m ? m.full_name : @name
    end

module() click to toggle source

Attempts to locate the included module object. Returns the name if not known.

The scoping rules of Ruby to resolve the name of an included module are:

- first look into the children of the current context;

- if not found, look into the children of included modules, in reverse inclusion order;

- if still not found, go up the hierarchy of names.

This method has `O(n!)` behavior when the module calling include is referencing nonexistent modules. Avoid calling module until after all the files are parsed. This behavior is due to ruby's constant lookup behavior.

As of the beginning of October, 2011, no gem includes nonexistent modules.

                   # File rdoc/mixin.rb, line 74
    def module
      return @module if @module

      # search the current context
      return @name unless parent
      full_name = parent.child_name(@name)
      @module = @store.modules_hash[full_name]
      return @module if @module
      return @name if @name =~ /^::/

      # search the includes before this one, in reverse order
      searched = parent.includes.take_while { |i| i != self }.reverse
      searched.each do |i|
        inc = i.module
        next if String === inc
        full_name = inc.child_name(@name)
        @module = @store.modules_hash[full_name]
        return @module if @module
      end

      # go up the hierarchy of names
      up = parent.parent
      while up
        full_name = up.child_name(@name)
        @module = @store.modules_hash[full_name]
        return @module if @module
        up = up.parent
      end

      @name
    end

store=(store) click to toggle source

Sets the store for this class or module and its contained code objects.

                   # File rdoc/mixin.rb, line 109
    def store= store
      super

      @file = @store.add_file @file.full_name if @file
    end