module DatastaxRails::AttributeMethods::PrimaryKey
Methods for working with PKs
Public Instance Methods
__id()
click to toggle source
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 31 def __id self.class.column_for_attribute(self.class.primary_key).type_cast_for_cql3(id) end
id()
click to toggle source
Returns the primary key value.
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 27 def id read_attribute(self.class.primary_key) end
id=(value)
click to toggle source
Sets the primary key value.
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 36 def id=(value) write_attribute(self.class.primary_key, value) if self.class.primary_key end
id?()
click to toggle source
Queries the primary key value.
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 41 def id? query_attribute(self.class.primary_key) end
id_for_destroy()
click to toggle source
Returns a primary key has for deletes. Payload models override this.
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 22 def id_for_destroy id_for_update end
id_for_update()
click to toggle source
Returns a primary key hash for updates. Wide models override this.
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 17 def id_for_update { self.class.primary_key.to_s => __id } end
to_key()
click to toggle source
Returns this record's primary key value wrapped in an Array if one is available.
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 11 def to_key key = id [key] if key end
Protected Instance Methods
attribute_method?(attr_name)
click to toggle source
Calls superclass method
# File lib/datastax_rails/attribute_methods/primary_key.rb, line 47 def attribute_method?(attr_name) attr_name == 'id' || super end