module Elastics::Model::HelperMethods

Public Class Methods

included(base) click to toggle source
# 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

Public Instance Methods

delete_elastics() click to toggle source
# File lib/elastics/model/helper_methods.rb, line 92
def delete_elastics
  self.class.request_elastics(method: :delete, id: id)
rescue NotFound
end
index_elastics() click to toggle source
# File lib/elastics/model/helper_methods.rb, line 80
def index_elastics
  self.class.request_elastics(method: :post, id: id, body: to_elastics)
end
update_elastics(data) click to toggle source
# File lib/elastics/model/helper_methods.rb, line 84
def update_elastics(data)
  self.class.request_elastics(method: :post, id: "#{id}/_update", body: data)
end
update_elastics_doc(fields) click to toggle source
# File lib/elastics/model/helper_methods.rb, line 88
def update_elastics_doc(fields)
  update_elastics(doc: fields)
end