Class: Compass::Search::Provider
- Inherits:
-
Object
- Object
- Compass::Search::Provider
- Includes:
- JsonFormatter, MustImplement, 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 MustImplement
Methods included from Rendering
Constructor Details
#initialize(**context) ⇒ Provider
Returns a new instance of Provider.
10 11 12 13 |
# File 'lib/compass/search/provider.rb', line 10 def initialize(**context) @context = context context.each { |key, value| define_singleton_method(key) { value } } end |
Class Method Details
.as_json ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/compass/search/provider.rb', line 26 def self.as_json(*) { provider: name, label: label, search_options: } end |
.label ⇒ Object
24 |
# File 'lib/compass/search/provider.rb', line 24 def self.label = name.to_s.gsub(/(Provider|Search)/i, "").pluralize |
Instance Method Details
#fetch_records(_query) ⇒ Object
19 |
# File 'lib/compass/search/provider.rb', line 19 def fetch_records(_query) = must_implement(:fetch_records) |
#search(query) ⇒ Object
15 16 17 |
# File 'lib/compass/search/provider.rb', line 15 def search(query) fetch_records(query).map { |record| format(record) } end |