Module: Penetrator::Concern
- Defined in:
- lib/penetrator.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/penetrator.rb', line 8 def self.extended(base) #:nodoc: base.instance_variable_set("@_dependencies", []) end |
Instance Method Details
#append_features(base) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/penetrator.rb', line 12 def append_features(base) if base.instance_variable_defined?("@_dependencies") base.instance_variable_get("@_dependencies") << self return false else return false if base < self @_dependencies.each { |dep| base.send(:include, dep) } super base.extend const_get("ClassMethods") if const_defined?("ClassMethods") return unless instance_variable_defined?("@_included_block") if @_trait_block base.class_exec(*@_trait_args, @_trait_block, &@_included_block) else base.class_exec(*@_trait_args, &@_included_block) end end end |
#extend_object(obj) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/penetrator.rb', line 30 def extend_object(obj) super return unless instance_variable_defined?("@_included_block") if @_trait_block (class << obj; self; end).instance_exec(*@_trait_args, @_trait_block, &@_included_block) else (class << obj; self; end).instance_exec(*@_trait_args, &@_included_block) end end |
#included(base = nil, &block) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/penetrator.rb', line 40 def included(base = nil, &block) if base.nil? @_included_block = block else super end end |