Class: EacRubyUtils::CommonConstructor::ClassInitialize
- Defined in:
- lib/eac_ruby_utils/common_constructor/class_initialize.rb
Instance Attribute Summary collapse
-
#common_constructor ⇒ Object
readonly
Returns the value of attribute common_constructor.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #define_initialize_callbacks ⇒ Object
- #define_initialize_method ⇒ Object
-
#initialize(common_constructor, klass) ⇒ ClassInitialize
constructor
A new instance of ClassInitialize.
- #perform ⇒ Object
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_constructor ⇒ Object (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 |
#klass ⇒ Object (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
#define_initialize_callbacks ⇒ Object
16 17 18 19 |
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 16 def define_initialize_callbacks klass.include(::ActiveSupport::Callbacks) klass.define_callbacks :initialize end |
#define_initialize_method ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 21 def define_initialize_method class_initialize = self klass.send(:define_method, :initialize) do |*args, &block| ::EacRubyUtils::CommonConstructor::InstanceInitialize.new( class_initialize.common_constructor, args, self, block ).perform super(*::EacRubyUtils::CommonConstructor::SuperArgs.new( class_initialize, args, self ).result) end end |
#perform ⇒ Object
33 34 35 36 |
# File 'lib/eac_ruby_utils/common_constructor/class_initialize.rb', line 33 def perform define_initialize_callbacks define_initialize_method end |