Class: Elastictastic::DiscretePersistenceStrategy
- Inherits:
-
Object
- Object
- Elastictastic::DiscretePersistenceStrategy
- Includes:
- Singleton
- Defined in:
- lib/elastictastic/discrete_persistence_strategy.rb
Instance Attribute Summary collapse
-
#auto_refresh ⇒ Object
Returns the value of attribute auto_refresh.
Instance Method Summary collapse
Instance Attribute Details
#auto_refresh ⇒ Object
Returns the value of attribute auto_refresh.
7 8 9 |
# File 'lib/elastictastic/discrete_persistence_strategy.rb', line 7 def auto_refresh @auto_refresh end |
Instance Method Details
#create(doc) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/elastictastic/discrete_persistence_strategy.rb', line 9 def create(doc) response = Elastictastic.client.create( doc.index, doc.class.type, doc.id, doc.elasticsearch_doc, params_for(doc) ) doc.id = response['_id'] doc.persisted! end |
#destroy(doc) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/elastictastic/discrete_persistence_strategy.rb', line 32 def destroy(doc) response = Elastictastic.client.delete( doc.index.name, doc.class.type, doc.id, params_for(doc) ) doc.transient! response['found'] end |
#update(doc) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/elastictastic/discrete_persistence_strategy.rb', line 21 def update(doc) Elastictastic.client.update( doc.index, doc.class.type, doc.id, doc.elasticsearch_doc, params_for(doc) ) doc.persisted! end |