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
100 101 102 |
# File 'lib/workarea/elasticsearch/document.rb', line 100 def as_bulk_document(action = :index) as_document.merge(Serializer.serialize(model)).merge(bulk_action: action) end |
#as_document ⇒ Object
93 94 95 96 97 98 |
# File 'lib/workarea/elasticsearch/document.rb', line 93 def as_document raise( NotImplementedError, "#{self.class} must implement #as_document to be saved" ) end |
#destroy(options = {}) ⇒ Object
111 112 113 |
# File 'lib/workarea/elasticsearch/document.rb', line 111 def destroy( = {}) I18n.for_each_locale { self.class.delete(id, ) } end |
#initialize(model, options = {}) ⇒ Object
88 89 90 91 |
# File 'lib/workarea/elasticsearch/document.rb', line 88 def initialize(model, = {}) @model = model @options = end |
#save(options = {}) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/workarea/elasticsearch/document.rb', line 104 def save( = {}) I18n.for_each_locale do document = as_document.merge(Serializer.serialize(model)) self.class.save(document, ) end end |