Class: Module

Inherits:
Object show all
Defined in:
lib/can_has_meta/core_ext/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#included_callbacksObject

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_blocksObject

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_blocksObject

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 included_with_meta(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
  
  included_without_meta(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