Module: MetaSearch::Searches::ActiveRecord::ClassMethods
- Defined in:
- lib/meta_search/searches/active_record.rb
Instance Method Summary collapse
- #_metasearch_association_authorized?(name, metasearch_object) ⇒ Boolean
- #_metasearch_attribute_authorized?(name, metasearch_object) ⇒ Boolean
- #_metasearch_method_authorized?(name, metasearch_object) ⇒ Boolean
-
#metasearch(params = nil, opts = nil) ⇒ Object
(also: #search)
Prepares the search to run against your model.
Instance Method Details
#_metasearch_association_authorized?(name, metasearch_object) ⇒ Boolean
63 64 65 66 67 68 69 70 |
# File 'lib/meta_search/searches/active_record.rb', line 63 def (name, ) name = name.to_s if self..empty? !(name, ) else (name, ) end end |
#_metasearch_attribute_authorized?(name, metasearch_object) ⇒ Boolean
54 55 56 57 58 59 60 61 |
# File 'lib/meta_search/searches/active_record.rb', line 54 def (name, ) name = name.to_s if self..empty? !(name, ) else (name, ) end end |
#_metasearch_method_authorized?(name, metasearch_object) ⇒ Boolean
48 49 50 51 52 |
# File 'lib/meta_search/searches/active_record.rb', line 48 def (name, ) name = name.to_s meth = self.[name] meth && (meth[:if] ? meth[:if].call() : true) end |
#metasearch(params = nil, opts = nil) ⇒ Object Also known as: search
Prepares the search to run against your model. Returns an instance of MetaSearch::Builder, which behaves pretty much like an ActiveRecord::Relation, in that it doesn’t actually query the database until you do something that requires it to do so.
Options:
-
params- a hash of valid searches with keys that are valid according to the docs in MetaSearch::Where. -
opts- A hash of additional information that will be passed through to the search’s Builder object.search_key, if present, will override the default param name, ‘search’, in any sort_links generated by this Builder. All other keys are passed untouched to the builder, and available from the Builder’soptionsreader for use in :if blocks supplied to attr_searchable and friends.
41 42 43 44 |
# File 'lib/meta_search/searches/active_record.rb', line 41 def (params = nil, opts = nil) builder = Searches.for(self).new(self, opts || {}) builder.build(params || {}) end |