Method: Elastify::ActiveRecordExtensions::ClassMethods#elastify_setup

Defined in:
lib/elastify/active_record_extensions.rb

#elastify_setup {|model| ... } ⇒ Object

Yields:

  • (model)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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