Module: CassandraObject::Core
- Included in:
- Base
- Defined in:
- lib/cassandra_object/core.rb
Instance Method Summary collapse
- #==(comparison_object) ⇒ Object
- #eql?(comparison_object) ⇒ Boolean
- #hash ⇒ Object
- #initialize(attributes = nil) {|_self| ... } ⇒ Object
- #initialize_dup(other) ⇒ Object
- #to_param ⇒ Object
Instance Method Details
#==(comparison_object) ⇒ Object
36 37 38 39 40 |
# File 'lib/cassandra_object/core.rb', line 36 def ==(comparison_object) comparison_object.equal?(self) || (comparison_object.instance_of?(self.class) && comparison_object.id == id) end |
#eql?(comparison_object) ⇒ Boolean
42 43 44 |
# File 'lib/cassandra_object/core.rb', line 42 def eql?(comparison_object) self == (comparison_object) end |
#hash ⇒ Object
32 33 34 |
# File 'lib/cassandra_object/core.rb', line 32 def hash id.hash end |
#initialize(attributes = nil) {|_self| ... } ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cassandra_object/core.rb', line 3 def initialize(attributes=nil) @new_record = true @destroyed = false @attributes = {} self.attributes = attributes || {} attribute_definitions.each do |attr, attribute_definition| unless attribute_exists?(attr) @attributes[attr.to_s] = self.class.typecast_attribute(self, attr, nil) end end yield self if block_given? end |
#initialize_dup(other) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cassandra_object/core.rb', line 17 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_param ⇒ Object
28 29 30 |
# File 'lib/cassandra_object/core.rb', line 28 def to_param id end |