Module: Tinia::Index::InstanceMethods

Defined in:
lib/tinia/index.rb

Instance Method Summary collapse

Instance Method Details

#add_to_cloud_searchObject

add ourself as a document to CloudSearch



20
21
22
23
24
# File 'lib/tinia/index.rb', line 20

def add_to_cloud_search
  self.class.cloud_search_add_document(
    self.cloud_search_document
  )
end

#cloud_search_dataObject

empty implementation - re-implement or we might end up doing some meta-programming here



28
29
30
# File 'lib/tinia/index.rb', line 28

def cloud_search_data
  {}
end

#cloud_search_documentObject

wrapper for a fully formed AWSCloudSearch::Document



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tinia/index.rb', line 33

def cloud_search_document
  AWSCloudSearch::Document.new.tap do |d|
    d.id = self.id
    d.lang = "en"
    d.version = self.updated_at.to_i
    # class name
    d.add_field("type", self.class.base_class.name)
    self.cloud_search_data.each_pair do |k,v|
      d.add_field(k.to_s, v.to_s)
    end
  end
end

#delete_from_cloud_searchObject

add ourself as a document to CloudSearch



47
48
49
50
51
# File 'lib/tinia/index.rb', line 47

def delete_from_cloud_search
  self.class.cloud_search_delete_document(
    self.cloud_search_document
  )
end