Package org.jruby

Class PrependedModule

All Implemented Interfaces:
Serializable, Cloneable, Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType

public class PrependedModule extends RubyClass
This class is used as an intermediate superclass for Module#prepend. It takes over all methods on the original module/class which is prepended and sets the originals methodLocation to this class. The orignial type no longer has methods so it will look down its inheritance chain to find them. The class which is actually prepended will be included onto the original type. This original method holding type will be put beneath the prepend module.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • moveRefinedMethod

      private boolean moveRefinedMethod(String key, DynamicMethod method, RubyModule klass)
      Transfer refined methods from the prepend stub to the origin as markers so they trigger refinements MRI: move_refined_method
    • isPrepended

      public boolean isPrepended()
      Overrides:
      isPrepended in class RubyModule
    • isModule

      public boolean isModule()
      Description copied from class: RubyBasicObject
      Specifically polymorphic method that are meant to be overridden by modules to specify that they are modules in an easy way.
      Specified by:
      isModule in interface IRubyObject
      Overrides:
      isModule in class RubyClass
      Returns:
      true if an object is Ruby Module instance (note that it will return false for Ruby Classes). If is_a? semantics is required, use (someObject instanceof RubyModule) instead.
    • isClass

      public boolean isClass()
      Description copied from class: RubyBasicObject
      Specifically polymorphic method that are meant to be overridden by classes to specify that they are classes in an easy way.
      Specified by:
      isClass in interface IRubyObject
      Overrides:
      isClass in class RubyClass
      Returns:
      true if an object is Ruby Class instance (note that it will return false for Ruby singleton classes). If is_a? semantics is required, use (someObject instanceof RubyClass/MetaClass) instead.
    • isImmediate

      public boolean isImmediate()
      Description copied from class: RubyBasicObject
      Is object immediate (def: Fixnum, Symbol, true, false, nil?).
      Specified by:
      isImmediate in interface IRubyObject
      Overrides:
      isImmediate in class RubyBasicObject
      Returns:
    • setMetaClass

      public void setMetaClass(RubyClass newRubyClass)
      Description copied from class: RubyBasicObject
      Makes it possible to change the metaclass of an object. In practice, this is a simple version of Smalltalks Become, except that it doesn't work when we're dealing with subclasses. In practice it's used to change the singleton/meta class used, without changing the "real" inheritance chain.
      Overrides:
      setMetaClass in class RubyBasicObject
    • getName

      public String getName()
      Description copied from class: RubyModule
      Generate a fully-qualified class name or a #-style name for anonymous and singleton classes. Ruby C equivalent = "classname"
      Overrides:
      getName in class RubyModule
      Returns:
      The generated class name
    • getOrigin

      public RubyModule getOrigin()
      Description copied from class: RubyModule
      In an included or prepended module what is the ACTUAL module it represents?
      Overrides:
      getOrigin in class RubyModule
      Returns:
      the actual module of an included/prepended module.
    • getNonIncludedClass

      @Deprecated public RubyModule getNonIncludedClass()
      Deprecated.
      Overrides:
      getNonIncludedClass in class RubyModule
    • id

      public IRubyObject id()
      We don't want to reveal ourselves to Ruby code, so origin this operation.
      Specified by:
      id in interface IRubyObject
      Overrides:
      id in class RubyBasicObject
      Returns:
      the object id
    • addMethod

      public void addMethod(String id, DynamicMethod method)
      Overrides:
      addMethod in class RubyModule
    • getClassVariables

      protected Map<String,IRubyObject> getClassVariables()
      Overrides:
      getClassVariables in class RubyModule
    • getClassVariablesForRead

      protected Map<String,IRubyObject> getClassVariablesForRead()
      Overrides:
      getClassVariablesForRead in class RubyModule
    • constantTableStore

      protected IRubyObject constantTableStore(String name, IRubyObject value)
      Overrides:
      constantTableStore in class RubyModule
    • constantTableStore

      protected IRubyObject constantTableStore(String name, IRubyObject value, boolean hidden)
      Overrides:
      constantTableStore in class RubyModule
    • constantTableRemove

      protected IRubyObject constantTableRemove(String name)
      Overrides:
      constantTableRemove in class RubyModule
    • getAutoloadConstant

      protected IRubyObject getAutoloadConstant(String name, boolean forceLoad)
      Overrides:
      getAutoloadConstant in class RubyModule
    • getAutoloadMap

      protected Map<String,RubyModule.Autoload> getAutoloadMap()
      Description copied from class: RubyModule
      AutoloadMap must be accessed after checking ConstantMap. Checking UNDEF value in constantMap works as a guard. For looking up constant, check constantMap first then try to get an Autoload object from autoloadMap. For setting constant, update constantMap first and remove an Autoload object from autoloadMap.
      Overrides:
      getAutoloadMap in class RubyModule
    • getAutoloadMapForWrite

      protected Map<String,RubyModule.Autoload> getAutoloadMapForWrite()
      Overrides:
      getAutoloadMapForWrite in class RubyModule