Module: Elastics::Model::HelperMethods
- Defined in:
- lib/elastics/model/helper_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #delete_elastics ⇒ Object
- #index_elastics ⇒ Object
- #update_elastics(data) ⇒ Object
- #update_elastics_doc(fields) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/elastics/model/helper_methods.rb', line 4 def self.included(base) base.class_eval do extend ClassMethods # don't override to_elastics method, if it already exists if !instance_methods.include?(:to_elastics) && instance_methods.include?(:as_json) alias_method :to_elastics, :as_json end end end |
Instance Method Details
#delete_elastics ⇒ Object
61 62 63 64 |
# File 'lib/elastics/model/helper_methods.rb', line 61 def delete_elastics self.class.request_elastics(method: :delete, id: id) rescue NotFound end |
#index_elastics ⇒ Object
49 50 51 |
# File 'lib/elastics/model/helper_methods.rb', line 49 def index_elastics self.class.request_elastics(method: :post, id: id, body: to_elastics) end |
#update_elastics(data) ⇒ Object
53 54 55 |
# File 'lib/elastics/model/helper_methods.rb', line 53 def update_elastics(data) self.class.request_elastics(method: :post, id: "#{id}/_update", body: data) end |
#update_elastics_doc(fields) ⇒ Object
57 58 59 |
# File 'lib/elastics/model/helper_methods.rb', line 57 def update_elastics_doc(fields) update_elastics(doc: fields) end |