Class: ClusterPoint::Document

Inherits:
OpenStruct
  • Object
show all
Extended by:
ActiveModel::Naming, Contains, ContainsMany, FinderMethods, HashMethods
Includes:
ActiveModel::Conversion, ActiveModel::Validations, JsonMethods, ModificationMethods
Defined in:
lib/cluster_point/document.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FinderMethods

all, find, get, where

Methods included from HashMethods

from_array, from_hash, like_array, remove_attribs

Methods included from Contains

clear_contains, contains, get_contains

Methods included from ContainsMany

clear_contains_many, contains_many, get_contains_many

Methods included from ModificationMethods

#destroy, #merge, #save, #update

Methods included from JsonMethods

#as_json

Instance Attribute Details

#idObject

Returns the value of attribute id.



16
17
18
# File 'lib/cluster_point/document.rb', line 16

def id
  @id
end

#typeObject

Returns the value of attribute type.



16
17
18
# File 'lib/cluster_point/document.rb', line 16

def type
  @type
end

Class Method Details

.get_cpObject



18
19
20
21
22
23
# File 'lib/cluster_point/document.rb', line 18

def self.get_cp
  if @cp == nil
    @cp = ClusterPoint::ClusterPointAdapter.new
  end
  @cp
end

.new_from_hash(hash) ⇒ Object



32
33
34
35
36
# File 'lib/cluster_point/document.rb', line 32

def self.new_from_hash(hash)
  doc=self.from_hash(hash, self)
  doc["type"] = self.to_s.upcase
  doc
end

Instance Method Details

#get_cpObject



25
26
27
28
29
30
# File 'lib/cluster_point/document.rb', line 25

def get_cp
  if @cp == nil
    @cp = ClusterPoint::ClusterPointAdapter.new
  end
  @cp
end

#persisted?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/cluster_point/document.rb', line 38

def persisted?
  id != nil
end