Module: Overridable::ModuleMixin

Defined in:
lib/overridable.rb

Overview

If your module includes this module, then classes which include your module will make their methods which also defined in your module overridable. Let’s watch an example: __NOTE__: If you need a custom ‘append_features` method in your module, define that method before include this module in yours, or this is not going to work.

Examples:

module YourModule
  include Overridable::ModuleMixin

  def foo
    super
    puts "foo in your module"
  end
end

class YourClass
  def foo
    puts "foo in your class"
  end
end

YourClass.new.foo #=> print: foo in your class\n

YourClass.send :include, YourModule

YourClass.new.foo #=> print: foo in your class\nfoo in your module\n
module YourModule
  def self.append_features mod
    # things ...
  end

  include Overridable::ModuleMixin
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.append_features(mod) ⇒ Object

:nodoc:



81
82
83
84
85
86
87
# File 'lib/overridable.rb', line 81

def self.append_features mod #:nodoc:
  class << mod
    include Overridable
    overrides :append_features
    include ClassMethods
  end
end