Module: Domain::DomainFactory

Defined in:
lib/domain/support/domain_factory.rb

Class Method Summary collapse

Class Method Details

.factor(c_methods = [], i_methods = []) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/domain/support/domain_factory.rb', line 4

def self.factor(c_methods = [], i_methods = [])
  i_methods, c_methods = Array(i_methods), Array(c_methods).unshift(Domain)
  Module.new{
    # include all class methods first
    c_methods.each{|c_m| include(c_m) }

    # Ensure that classes that are extended will include all instance methods
    define_singleton_method(:extend_object) do |obj|
      if obj.is_a?(Class)
        obj.module_eval{ i_methods.each{|i_m| include(i_m) } }
      end
      super(obj)
    end
  }
end