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



49
50
51
52
53
# File 'lib/cassandra_object/core.rb', line 49

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

#eql?(comparison_object) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashObject



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

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
  @attributes = {}
  self.attributes = attributes || {}
  attribute_definitions.each_value do |definition|
    unless definition.default.nil? || attribute_exists?(definition.name)
      @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)
  @attributes = other.attributes
  @attributes['created_at'] = nil
  @attributes['updated_at'] = nil
  @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