Class: Module
Instance Attribute Summary collapse
-
#included_callbacks ⇒ Object
Returns the value of attribute included_callbacks.
-
#macro_blocks ⇒ Object
Returns the value of attribute macro_blocks.
-
#mixin_blocks ⇒ Object
Returns the value of attribute mixin_blocks.
Instance Method Summary collapse
- #included_callback(&block) ⇒ Object
- #included_with_meta(base, &block) ⇒ Object (also: #included)
- #macros(&block) ⇒ Object
- #mixins(&block) ⇒ Object
Instance Attribute Details
#included_callbacks ⇒ Object
Returns the value of attribute included_callbacks.
2 3 4 |
# File 'lib/can_has_meta/core_ext/module.rb', line 2 def included_callbacks @included_callbacks end |
#macro_blocks ⇒ Object
Returns the value of attribute macro_blocks.
2 3 4 |
# File 'lib/can_has_meta/core_ext/module.rb', line 2 def macro_blocks @macro_blocks end |
#mixin_blocks ⇒ Object
Returns the value of attribute mixin_blocks.
2 3 4 |
# File 'lib/can_has_meta/core_ext/module.rb', line 2 def mixin_blocks @mixin_blocks end |
Instance Method Details
#included_callback(&block) ⇒ Object
29 30 31 |
# File 'lib/can_has_meta/core_ext/module.rb', line 29 def included_callback(&block) @included_callbacks ||= [] << block end |
#included_with_meta(base, &block) ⇒ Object Also known as: included
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/can_has_meta/core_ext/module.rb', line 12 def (base, &block) if base.class == Module (@macro_blocks ||= []).each {|mb| (base.macro_blocks ||= []) << mb} (@mixin_blocks ||= []).each {|mb| (base.mixin_blocks ||= []) << mb} (@included_callbacks ||= []).each {|ic| base.included_callbacks << ic} elsif base.class == Class (@macro_blocks ||= []).each {|mb| base.class.class_eval(&mb)} (@mixin_blocks ||= []).each {|mb| base.class_eval(&mb)} (@included_callbacks ||= []).each {|ic| base.instance_eval(&ic)} end (base, &block) end |
#macros(&block) ⇒ Object
4 5 6 |
# File 'lib/can_has_meta/core_ext/module.rb', line 4 def macros(&block) @macro_blocks ||= [] << block end |
#mixins(&block) ⇒ Object
8 9 10 |
# File 'lib/can_has_meta/core_ext/module.rb', line 8 def mixins(&block) @mixin_blocks ||= [] << block end |