Module: SnFoil::Searcher
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/snfoil/searcher.rb,
lib/snfoil/searcher/boolean.rb,
lib/snfoil/searcher/version.rb
Overview
Defined Under Namespace
Classes: ArgumentError, Boolean, Error
Constant Summary
collapse
- VERSION =
'1.1.0'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#scope ⇒ Object
72
73
74
|
# File 'lib/snfoil/searcher.rb', line 72
def scope
@scope
end
|
Instance Method Details
#booleans ⇒ Object
97
98
99
|
# File 'lib/snfoil/searcher.rb', line 97
def booleans
self.class.snfoil_booleans || []
end
|
#filter ⇒ Object
87
|
# File 'lib/snfoil/searcher.rb', line 87
def filter; end
|
#filters ⇒ Object
93
94
95
|
# File 'lib/snfoil/searcher.rb', line 93
def filters
self.class.snfoil_filters || []
end
|
#initialize(scope: nil) ⇒ Object
74
75
76
77
78
|
# File 'lib/snfoil/searcher.rb', line 74
def initialize(scope: nil)
raise SnFoil::Searcher::Error, "No default scope or model configured for #{self.class.name}" if !scope && !model
@scope = scope || model.all
end
|
#model ⇒ Object
68
69
70
|
# File 'lib/snfoil/searcher.rb', line 68
def model
self.class.snfoil_model
end
|
#search(params = {}) ⇒ Object
80
81
82
83
84
85
|
# File 'lib/snfoil/searcher.rb', line 80
def search(params = {})
params = transform_params_booleans(params) filtered_scope = filter || scope filtered_scope = apply_setup(filtered_scope, params)
apply_filters(filtered_scope, params)
end
|
#setup ⇒ Object
89
90
91
|
# File 'lib/snfoil/searcher.rb', line 89
def setup
self.class.snfoil_setup
end
|