11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# 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
|