Class: EacRubyUtils::CommonConstructor::ClassInitialize

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/common_constructor/class_initialize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(common_constructor, klass) ⇒ ClassInitialize

Returns a new instance of ClassInitialize.


11
12
13
14
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 11

def initialize(common_constructor, klass)
  @common_constructor = common_constructor
  @klass = klass
end

Instance Attribute Details

#common_constructorObject (readonly)

Returns the value of attribute common_constructor


9
10
11
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 9

def common_constructor
  @common_constructor
end

#klassObject (readonly)

Returns the value of attribute klass


9
10
11
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 9

def klass
  @klass
end

Instance Method Details

#runObject


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 16

def run
  class_initialize = self
  klass.send(:define_method, :initialize) do |*args|
    ::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
      class_initialize.common_constructor, args, self
    ).run
    super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
      class_initialize, args, self
    ).result)
  end
end