Module: ActiveAttr::ChainableInitialization
- Included in:
- AttributeDefaults, BlockInitialization, MassAssignment
- Defined in:
- lib/active_attr/chainable_initialization.rb
Overview
Allows classes and modules to safely invoke super in its initialize method
Many ActiveAttr modules enhance the behavior of the #initialize method, and in doing so, these methods need to accept arguments. However, Ruby’s Object and BasicObject classes, in most versions of Ruby, do not allow any arguments to be passed in. This module halts the propagation of initialization arguments before invoking the Object class’ initialization.
In order to still allow a subclass mixing in this module (directly or through an ActiveSupport::Concern) to still pass its initialization arguments to its superclass, the module has to install itself into the ancestors of the base class, the class that inherits directly from Object or BasicObject.
Instance Method Summary collapse
-
#initialize ⇒ Object
Continue to propagate any superclass calls, but stop passing arguments.
Instance Method Details
#initialize ⇒ Object
Continue to propagate any superclass calls, but stop passing arguments
This prevents problems in versions of Ruby where Object#initialize does not take arguments
43 44 45 |
# File 'lib/active_attr/chainable_initialization.rb', line 43 def initialize(*) super() end |