Module: Workarea::Elasticsearch::Document
- Extended by:
- ActiveSupport::Concern
- Included in:
- Search::Admin, Search::Help, Search::Storefront
- Defined in:
- lib/workarea/elasticsearch/document.rb
Class Method Summary collapse
Instance Method Summary collapse
- #as_bulk_document(action = :index) ⇒ Object
- #as_document ⇒ Object
- #destroy(options = {}) ⇒ Object
- #initialize(model, options = {}) ⇒ Object
- #save(options = {}) ⇒ Object
Class Method Details
Instance Method Details
#as_bulk_document(action = :index) ⇒ Object
95 96 97 |
# File 'lib/workarea/elasticsearch/document.rb', line 95 def as_bulk_document(action = :index) as_document.merge(Serializer.serialize(model)).merge(bulk_action: action) end |
#as_document ⇒ Object
88 89 90 91 92 93 |
# File 'lib/workarea/elasticsearch/document.rb', line 88 def as_document raise( NotImplementedError, "#{self.class} must implement #as_document to be saved" ) end |
#destroy(options = {}) ⇒ Object
104 105 106 |
# File 'lib/workarea/elasticsearch/document.rb', line 104 def destroy( = {}) self.class.delete(id, ) end |
#initialize(model, options = {}) ⇒ Object
83 84 85 86 |
# File 'lib/workarea/elasticsearch/document.rb', line 83 def initialize(model, = {}) @model = model @options = end |
#save(options = {}) ⇒ Object
99 100 101 102 |
# File 'lib/workarea/elasticsearch/document.rb', line 99 def save( = {}) document = as_document.merge(Serializer.serialize(model)) self.class.save(document, ) end |