Class: GOM::Storage::ElasticSearch::Adapter
- Inherits:
-
Adapter
- Object
- Adapter
- GOM::Storage::ElasticSearch::Adapter
- Defined in:
- lib/gom/storage/elastic_search/adapter.rb
Overview
The ElasticSearch storage adapter.
Instance Attribute Summary collapse
-
#storage_configuration ⇒ Object
readonly
Returns the value of attribute storage_configuration.
Instance Method Summary collapse
- #collection(name, options = { }) ⇒ Object
- #fetch(id) ⇒ Object
- #remove(id) ⇒ Object
- #setup ⇒ Object
- #store(draft) ⇒ Object
- #teardown ⇒ Object
Instance Attribute Details
#storage_configuration ⇒ Object (readonly)
Returns the value of attribute storage_configuration.
6 7 8 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 6 def storage_configuration @storage_configuration end |
Instance Method Details
#collection(name, options = { }) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 31 def collection(name, = { }) view = configuration.views[name.to_sym] raise ArgumentError, "the given view #{name} isn't defined!'" unless view query_string = build_query view.class_name, [:query] search = Tire.search @index_name do query { string query_string } end GOM::Object::Collection.new GOM::Storage::ElasticSearch::Collection::Fetcher.new(search.results), configuration.name end |
#fetch(id) ⇒ Object
19 20 21 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 19 def fetch(id) storage_adapter.fetch id end |
#remove(id) ⇒ Object
27 28 29 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 27 def remove(id) storage_adapter.remove id end |
#setup ⇒ Object
8 9 10 11 12 13 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 8 def setup setup_connection setup_index assign_storage setup_river end |
#store(draft) ⇒ Object
23 24 25 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 23 def store(draft) storage_adapter.store draft end |
#teardown ⇒ Object
15 16 17 |
# File 'lib/gom/storage/elastic_search/adapter.rb', line 15 def teardown end |