module Hoodoo::ActiveRecord::Finder
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:
…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.
Public Class Methods
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.
# 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
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.
# 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