Class: Compass::Search::Provider
- Inherits:
-
Object
- Object
- Compass::Search::Provider
- Includes:
- JsonFormatter, Rendering
- Defined in:
- lib/compass/search/provider.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_records(_query) ⇒ Object
-
#initialize(**context) ⇒ Provider
constructor
A new instance of Provider.
- #search(query) ⇒ Object
Methods included from Rendering
Constructor Details
#initialize(**context) ⇒ Provider
Returns a new instance of Provider.
9 10 11 12 |
# File 'lib/compass/search/provider.rb', line 9 def initialize(**context) @context = context context.each { |key, value| define_singleton_method(key) { value } } end |
Class Method Details
.as_json ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/compass/search/provider.rb', line 25 def self.as_json(*) { provider: name, label: label, search_options: } end |
.label ⇒ Object
23 |
# File 'lib/compass/search/provider.rb', line 23 def self.label = name.to_s.gsub(/(Provider|Search)/i, "").pluralize |
Instance Method Details
#fetch_records(_query) ⇒ Object
18 |
# File 'lib/compass/search/provider.rb', line 18 def fetch_records(_query) = must_implement(:fetch_records) |
#search(query) ⇒ Object
14 15 16 |
# File 'lib/compass/search/provider.rb', line 14 def search(query) fetch_records(query).map { |record| format(record) } end |