Module: Elastify::ActiveRecordExtensions::ClassMethods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/elastify/active_record_extensions.rb
Instance Method Summary collapse
- #elastify_model(model_name) {|model| ... } ⇒ Object
- #elastify_scroll(scroll_id: nil, scroll_timeout: nil) ⇒ Object
- #elastify_search(dsl: nil, scroll_timeout: nil) ⇒ Object
- #elastify_setup {|model| ... } ⇒ Object
Instance Method Details
#elastify_model(model_name) {|model| ... } ⇒ Object
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. = {} if self..blank? self.[:base_url] = Elastify.configs.base_url self.[:index] = model.opt_index if model.opt_index.present? self.[:type] = model.opt_type if model.opt_type.present? self.[:map] = model.opt_mapping if model.opt_mapping.present? self.[:decode] = model.opt_decode if model.opt_decode.present? self.[:encode] = model.opt_encode if model.opt_encode.present? self.[:scroll_timeout] = model.opt_scroll_timeout if model.opt_scroll_timeout.present? end |
#elastify_scroll(scroll_id: nil, scroll_timeout: nil) ⇒ Object
49 50 51 |
# File 'lib/elastify/active_record_extensions.rb', line 49 def elastify_scroll(scroll_id: nil, scroll_timeout: nil) Elastify::Helpers::ElasticSearch::Document.new(self.).scroll(scroll_id, scroll_timeout) end |
#elastify_search(dsl: nil, scroll_timeout: nil) ⇒ Object
45 46 47 |
# File 'lib/elastify/active_record_extensions.rb', line 45 def elastify_search(dsl: nil, scroll_timeout: nil) Elastify::Helpers::ElasticSearch::Document.new(self.).search(dsl, scroll_timeout) end |
#elastify_setup {|model| ... } ⇒ Object
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. = {} if self..blank? self.[:base_url] = Elastify.configs.base_url self.[:index] = model.opt_index if model.opt_index.present? self.[:type] = model.opt_type if model.opt_type.present? self.[:map] = model.opt_mapping if model.opt_mapping.present? self.[:decode] = model.opt_decode if model.opt_decode.present? self.[:encode] = model.opt_encode if model.opt_encode.present? self.[:scroll_timeout] = model.opt_scroll_timeout if model.opt_scroll_timeout.present? end |