Module: Hoodoo::ActiveRecord::Creator
- Defined in:
- lib/hoodoo/active/active_record/creator.rb
Overview
Support mixin for models subclassed from ActiveRecord::Base providing context-aware model instance creation, allowing service authors to auto-inherit related features from Hoodoo without changing their code.
It is STRONGLY RECOMMENDED that you use the likes of:
-
Hoodoo::ActiveRecord::Creator::ClassMethods::new_in
…to create model instances and participate “for free” in whatever plug-in ActiveRecord modules are mixed into the model classes, such as Hoodoo::ActiveRecord::Dated and Hoodoo::ActiveRecord::ManuallyDated.
See also:
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(model) ⇒ Object
Instantiates this module when it is included.
-
.instantiate(model) ⇒ Object
When instantiated in an ActiveRecord::Base subclass, all of the Hoodoo::ActiveRecord::Dated::ClassMethods methods are defined as class methods on the including class.
Class Method Details
.included(model) ⇒ Object
Instantiates this module when it is included.
Example:
class SomeModel < ActiveRecord::Base
include Hoodoo::ActiveRecord::Creator
# ...
end
model
-
The ActiveRecord::Base descendant that is including this module.
53 54 55 56 |
# File 'lib/hoodoo/active/active_record/creator.rb', line 53 def self.included( model ) instantiate( model ) unless model == Hoodoo::ActiveRecord::Base super( model ) end |
.instantiate(model) ⇒ Object
When instantiated in an ActiveRecord::Base subclass, all of the Hoodoo::ActiveRecord::Dated::ClassMethods methods are defined as class methods on the including class.
model
-
The ActiveRecord::Base descendant that is including this module.
65 66 67 |
# File 'lib/hoodoo/active/active_record/creator.rb', line 65 def self.instantiate( model ) model.extend( ClassMethods ) end |