Module: ModuleMethods::Extension
- Defined in:
- lib/module_methods/extension.rb
Overview
Module for module methods, because this module can be included into other modules before including into classes.
Instance Method Summary collapse
-
#included(base = nil) { ... } ⇒ Object
Main logic, which will be applied after extending with this module.
-
#modules_with_class_methods ⇒ Object
Getter for saving the whole chain of including and extending (nested ‘ClassMethods`).
Instance Method Details
#included(base = nil) { ... } ⇒ Object
Main logic, which will be applied after extending with this module
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/module_methods/extension.rb', line 17 def included(base = nil, &block) super return unless base if base.instance_of? Module base.extend ::ModuleMethods::Extension base.modules_with_class_methods.unshift(*modules_with_class_methods) end modules_with_class_methods.each do |module_with_class_methods| next unless module_with_class_methods.const_defined?(:ClassMethods, false) base.extend module_with_class_methods::ClassMethods end end |
#modules_with_class_methods ⇒ Object
Getter for saving the whole chain of including and extending (nested ‘ClassMethods`)
8 9 10 |
# File 'lib/module_methods/extension.rb', line 8 def modules_with_class_methods @modules_with_class_methods ||= [self] end |