Module: CassandraObject::Core

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/cassandra_object/core.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#==(comparison_object) ⇒ Object



53
54
55
56
57
# File 'lib/cassandra_object/core.rb', line 53

def ==(comparison_object)
  comparison_object.equal?(self) ||
    (comparison_object.instance_of?(self.class) &&
      comparison_object.id == id)
end

#eql?(comparison_object) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/cassandra_object/core.rb', line 59

def eql?(comparison_object)
  self == (comparison_object)
end

#get_cql_responseObject



34
35
36
# File 'lib/cassandra_object/core.rb', line 34

def get_cql_response
  self.class.cql_response.find(self.id)
end

#hashObject



38
39
40
# File 'lib/cassandra_object/core.rb', line 38

def hash
  id.hash
end

#initialize(attributes = nil) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cassandra_object/core.rb', line 5

def initialize(attributes=nil)
  @new_record = true
  @destroyed = false
  @model_attributes = {}
  self.attributes = attributes || {}
  attribute_definitions.each_value do |definition|
    unless definition.default.nil? || attribute_exists?(definition.name)
      @model_attributes[definition.name] = definition.default
    end
  end

  yield self if block_given?
end

#initialize_dup(other) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/cassandra_object/core.rb', line 19

def initialize_dup(other)
  @model_attributes = other.attributes
  @model_attributes['created_at'] = nil
  @model_attributes['updated_at'] = nil
  @model_attributes.delete(self.class.primary_key)
  @id = nil
  @new_record = true
  @destroyed = false
  super
end

#to_paramObject



30
31
32
# File 'lib/cassandra_object/core.rb', line 30

def to_param
  id
end