module Elastify::ActiveRecordExtensions::ClassMethods

Public Instance Methods

elastify_model(model_name) { |model| ... } click to toggle source
# File lib/elastify/active_record_extensions.rb, line 11
def elastify_model(model_name)
    include Elastify::ActiveRecordExtensions::LocalMethods
    cattr_accessor :elastify_options
    attr_accessor :elastify_serialized_document

    model = Elastify.models[model_name.to_sym]
    yield(model) if block_given?
    self.elastify_options = {} if self.elastify_options.blank?
    self.elastify_options[:base_url] = Elastify.configs.base_url
    self.elastify_options[:index] = model.opt_index if model.opt_index.present?
    self.elastify_options[:type] = model.opt_type if model.opt_type.present?
    self.elastify_options[:map] = model.opt_mapping if model.opt_mapping.present?
    self.elastify_options[:decode] = model.opt_decode if model.opt_decode.present?
    self.elastify_options[:encode] = model.opt_encode if model.opt_encode.present?
    self.elastify_options[:scroll_timeout] = model.opt_scroll_timeout if model.opt_scroll_timeout.present?
end
elastify_scroll(scroll_id: nil, scroll_timeout: nil) click to toggle source
# File lib/elastify/active_record_extensions.rb, line 49
def elastify_scroll(scroll_id: nil, scroll_timeout: nil)
    Elastify::Helpers::ElasticSearch::Document.new(self.elastify_options).scroll(scroll_id, scroll_timeout)
end
elastify_setup() { |model| ... } click to toggle source
# File lib/elastify/active_record_extensions.rb, line 28
def elastify_setup
    include Elastify::ActiveRecordExtensions::LocalMethods
    cattr_accessor :elastify_options
    attr_accessor :elastify_serialized_document

    model = Elastify::Model.new
    yield(model) if block_given?
    self.elastify_options = {} if self.elastify_options.blank?
    self.elastify_options[:base_url] = Elastify.configs.base_url
    self.elastify_options[:index] = model.opt_index if model.opt_index.present?
    self.elastify_options[:type] = model.opt_type if model.opt_type.present?
    self.elastify_options[:map] = model.opt_mapping if model.opt_mapping.present?
    self.elastify_options[:decode] = model.opt_decode if model.opt_decode.present?
    self.elastify_options[:encode] = model.opt_encode if model.opt_encode.present?
    self.elastify_options[:scroll_timeout] = model.opt_scroll_timeout if model.opt_scroll_timeout.present?
end