Class: Enumerize::Module

Inherits:
Module
  • Object
show all
Defined in:
lib/enumerize/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModule

Returns a new instance of Module.


7
8
9
10
11
12
13
# File 'lib/enumerize/module.rb', line 7

def initialize
  super

  @_class_methods   = ::Module.new
  @_dependents      = []
  @_dependent_evals = []
end

Instance Attribute Details

#_class_methodsObject (readonly)

Returns the value of attribute _class_methods


5
6
7
# File 'lib/enumerize/module.rb', line 5

def _class_methods
  @_class_methods
end

Instance Method Details

#dependent_eval(&block) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/enumerize/module.rb', line 25

def dependent_eval(&block)
  @_dependents.each do |klass|
    klass.instance_eval(&block)
  end

  @_dependent_evals << block
end

#included(klass) ⇒ Object


15
16
17
18
19
20
21
22
23
# File 'lib/enumerize/module.rb', line 15

def included(klass)
  klass.extend _class_methods

  @_dependent_evals.each do |block|
    klass.instance_eval(&block)
  end

  @_dependents << klass
end