Module: DatastaxRails::AttributeMethods::PrimaryKey
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/datastax_rails/attribute_methods/primary_key.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #__id ⇒ Object
-
#id ⇒ Object
Returns the primary key value.
-
#id=(value) ⇒ Object
Sets the primary key value.
-
#id? ⇒ Boolean
Queries the primary key value.
-
#id_for_update ⇒ Object
Returns a primary key hash for updates.
-
#to_key ⇒ Object
Returns this record’s primary key value wrapped in an Array if one is available.
Instance Method Details
#__id ⇒ Object
25 26 27 |
# File 'lib/datastax_rails/attribute_methods/primary_key.rb', line 25 def __id self.class.column_for_attribute(self.class.primary_key).type_cast_for_cql3(id) end |
#id ⇒ Object
Returns the primary key value.
21 22 23 |
# File 'lib/datastax_rails/attribute_methods/primary_key.rb', line 21 def id read_attribute(self.class.primary_key) end |
#id=(value) ⇒ Object
Sets the primary key value.
30 31 32 |
# File 'lib/datastax_rails/attribute_methods/primary_key.rb', line 30 def id=(value) write_attribute(self.class.primary_key, value) if self.class.primary_key end |
#id? ⇒ Boolean
Queries the primary key value.
35 36 37 |
# File 'lib/datastax_rails/attribute_methods/primary_key.rb', line 35 def id? query_attribute(self.class.primary_key) end |
#id_for_update ⇒ Object
Returns a primary key hash for updates. Wide models override this.
16 17 18 |
# File 'lib/datastax_rails/attribute_methods/primary_key.rb', line 16 def id_for_update { self.class.primary_key.to_s => __id } end |
#to_key ⇒ Object
Returns this record’s primary key value wrapped in an Array if one is available.
10 11 12 13 |
# File 'lib/datastax_rails/attribute_methods/primary_key.rb', line 10 def to_key key = id [key] if key end |