Module: CassandraObject::Core
Defined Under Namespace
Modules: ClassMethods
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
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
55 56 57 |
# File 'lib/cassandra_object/core.rb', line 55 def eql?(comparison_object) self == (comparison_object) end |
#hash ⇒ Object
34 35 36 |
# File 'lib/cassandra_object/core.rb', line 34 def hash id.hash end |
#initialize(attributes = nil) {|_self| ... } ⇒ Object
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 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
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_param ⇒ Object
30 31 32 |
# File 'lib/cassandra_object/core.rb', line 30 def to_param id end |