Module: ElasticRecord::Model

Defined in:
lib/elastic_record/model.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/elastic_record/model.rb', line 3

def self.included(base)
  base.class_eval do
    extend Searching
    extend ClassMethods
    extend FromSearchHit
    include Callbacks
    include AsDocument

    class_attribute :elastic_connection
    self.elastic_connection = ElasticRecord::Connection.new(ElasticRecord::Config.servers, ElasticRecord::Config.connection_options)

    singleton_class.delegate :query, :filter, :aggregate, to: :elastic_search
  end
end

Instance Method Details

#arelasticObject



46
47
48
# File 'lib/elastic_record/model.rb', line 46

def arelastic
  self.class.arelastic
end

#elastic_indexObject



50
51
52
# File 'lib/elastic_record/model.rb', line 50

def elastic_index
  self.class.elastic_index
end

#index_to_elasticsearchObject



42
43
44
# File 'lib/elastic_record/model.rb', line 42

def index_to_elasticsearch
  elastic_index.index_record(self)
end