Class: Module
- Includes:
- CoreEx::Module::AttrOnce, CoreEx::Module::Import, CoreEx::Module::InPlace, CoreEx::Module::MixInWithArgs
- Defined in:
- lib/core_ex.rb,
lib/core_ex.rb,
lib/core_ex/module/mix_in_with_args.rb
Overview
class String
Instance Method Summary collapse
- #include(*someModules) ⇒ Object
- #include_without_setup_call ⇒ Object
- #mixin(aModule, *args) ⇒ Object (also: #make, #have)
-
#setup(&block) ⇒ Object
Register the setup block.
-
#teardown(&block) ⇒ Object
Register the teardown block.
Methods included from CoreEx::Module::InPlace
Methods included from CoreEx::Module::Import
Methods included from CoreEx::Module::AttrOnce
Instance Method Details
#include(*someModules) ⇒ Object
44 45 46 47 48 |
# File 'lib/core_ex/module/mix_in_with_args.rb', line 44 def include ( *someModules ) someModules.each do |aModule| mixin aModule end end |
#include_without_setup_call ⇒ Object
42 |
# File 'lib/core_ex/module/mix_in_with_args.rb', line 42 alias_method :include_without_setup_call, :include |
#mixin(aModule, *args) ⇒ Object Also known as: make, have
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/core_ex/module/mix_in_with_args.rb', line 50 def mixin ( aModule, *args ) pair = [self, aModule] return if mix_in_initialized.include? pair call_block(:setup, aModule, *args) include_without_setup_call aModule extend aModule::ClassMethods if aModule.const_defined? :ClassMethods call_block(:teardown, aModule, *args) mix_in_initialized << pair self end |
#setup(&block) ⇒ Object
Register the setup block
17 18 19 |
# File 'lib/core_ex/module/mix_in_with_args.rb', line 17 def setup ( &block ) blocks[[:setup, self]] = block unless block.nil? end |
#teardown(&block) ⇒ Object
Register the teardown block
22 23 24 |
# File 'lib/core_ex/module/mix_in_with_args.rb', line 22 def teardown ( &block ) blocks[[:teardown, self]] = block unless block.nil? end |