Module: Hoodoo::ActiveRecord::Finder
- Defined in:
- lib/hoodoo/active/active_record/finder.rb,
lib/hoodoo/active/active_record/search_helper.rb
Overview
Mixin for models subclassed from ActiveRecord::Base providing support methods to handle common show
and list
filtering actions based on inbound data and create instances in a request context aware fashion.
It is STRONGLY RECOMMENDED that you use the likes of:
-
Hoodoo::ActiveRecord::Finder::ClassMethods#acquire_in
-
Hoodoo::ActiveRecord::Finder::ClassMethods#list_in
…to retrieve model data related to resource instances and participate “for free” in whatever plug-in ActiveRecord modules are mixed into the model classes, such as Hoodoo::ActiveRecord::Secure.
See also:
Dependency Hoodoo::ActiveRecord::Secure is included automatically.
Defined Under Namespace
Modules: ClassMethods Classes: SearchHelper
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::Finder::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::Finder
# ...
end
Depends upon and auto-includes Hoodoo::ActiveRecord::Secure.
model
-
The ActiveRecord::Base descendant that is including this module.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hoodoo/active/active_record/finder.rb', line 52 def self.included( model ) model.class_attribute( :nz_co_loyalty_hoodoo_show_id_fields, :nz_co_loyalty_hoodoo_show_id_substitute, :nz_co_loyalty_hoodoo_estimate_counts_with, :nz_co_loyalty_hoodoo_search_with, :nz_co_loyalty_hoodoo_filter_with, :instance_predicate => false, :instance_accessor => false ) unless model == Hoodoo::ActiveRecord::Base model.send( :include, Hoodoo::ActiveRecord::Secure ) instantiate( model ) end super( model ) end |
.instantiate(model) ⇒ Object
When instantiated in an ActiveRecord::Base subclass, all of the Hoodoo::ActiveRecord::Finder::ClassMethods methods are defined as class methods on the including class.
This module depends upon Hoodoo::ActiveRecord::Secure, so that will be auto-included first if it isn’t already.
model
-
The ActiveRecord::Base descendant that is including this module.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/hoodoo/active/active_record/finder.rb', line 81 def self.instantiate( model ) model.extend( ClassMethods ) framework_data = Hoodoo::ActiveRecord::Support.framework_search_and_filter_data() model.nz_co_loyalty_hoodoo_search_with ||= {} model.nz_co_loyalty_hoodoo_filter_with ||= {} model.nz_co_loyalty_hoodoo_search_with.merge!( framework_data ) model.nz_co_loyalty_hoodoo_filter_with.merge!( framework_data ) end |