Class: Landable::SearchEngine
- Inherits:
-
Object
- Object
- Landable::SearchEngine
show all
- Defined in:
- app/models/landable/search_engine.rb
Instance Method Summary
collapse
Constructor Details
#initialize(base_scope, filters, options = {}) ⇒ SearchEngine
Returns a new instance of SearchEngine.
3
4
5
6
7
8
9
10
|
# File 'app/models/landable/search_engine.rb', line 3
def initialize(base_scope, filters, options = {})
@scope = base_scope
order! options[:order]
limit! options[:limit]
filter_by!(filters)
end
|
Instance Method Details
#filter_by!(filters) ⇒ Object
20
21
22
|
# File 'app/models/landable/search_engine.rb', line 20
def filter_by!(filters)
raise NotImplementedError
end
|
#limit!(limit) ⇒ Object
28
29
30
|
# File 'app/models/landable/search_engine.rb', line 28
def limit!(limit)
@scope = @scope.limit(limit) if limit
end
|
16
17
18
|
# File 'app/models/landable/search_engine.rb', line 16
def meta
{ search: { total_results: @scope.count(:all) } }
end
|
#order!(order) ⇒ Object
24
25
26
|
# File 'app/models/landable/search_engine.rb', line 24
def order!(order)
@scope = @scope.order(order) if order
end
|
#results ⇒ Object
12
13
14
|
# File 'app/models/landable/search_engine.rb', line 12
def results
@scope
end
|