Class: Searchlight::Search
- Inherits:
-
Object
- Object
- Searchlight::Search
- Extended by:
- DSL
- Defined in:
- lib/searchlight/search.rb
Defined Under Namespace
Classes: UndefinedOption
Instance Attribute Summary collapse
- #search ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Search
constructor
A new instance of Search.
- #options ⇒ Object
- #results ⇒ Object
Methods included from DSL
Constructor Details
#initialize(options = {}) ⇒ Search
Returns a new instance of Search.
11 12 13 |
# File 'lib/searchlight/search.rb', line 11 def initialize( = {}) filter_and_mass_assign() end |
Instance Attribute Details
#search ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/searchlight/search.rb', line 15 def search @search ||= begin target = self.class.search_target if callable?(target) # for delayed scope evaluation target.call else target end end end |
Class Method Details
.search_target ⇒ Object
5 6 7 8 9 |
# File 'lib/searchlight/search.rb', line 5 def self.search_target return @search_target if defined?(@search_target) return superclass.search_target if superclass.respond_to?(:search_target) && superclass != Searchlight::Search guess_search_class! end |
Instance Method Details
#options ⇒ Object
31 32 33 34 35 36 |
# File 'lib/searchlight/search.rb', line 31 def search_attributes.reduce({}) { |hash, option_name| option_val = send(option_name) hash.tap { |hash| hash[option_name.to_sym] = option_val unless is_blank?(option_val) } } end |
#results ⇒ Object
27 28 29 |
# File 'lib/searchlight/search.rb', line 27 def results @results ||= run end |