Class: Cequel::Record::Map
- Inherits:
-
Hash
- Object
- Hash
- Cequel::Record::Map
- Extended by:
- Forwardable
- Includes:
- Collection
- Defined in:
- lib/cequel/record/collection.rb
Overview
The value of a ‘map` column in a Cequel::Record instance. Encapsulates and behaves like a built-in `Hash`.
Constant Summary collapse
- NON_ATOMIC_MUTATORS =
These methods involve mutation that cannot be expressed as a CQL operation, so are not implemented.
[ :default, :default=, :default_proc, :default_proc=, :delete_if, :deep_merge!, :except!, :extract!, :keep_if, :reject!, :reverse_merge!, :reverse_update, :select!, :shift, :slice!, :stringify_keys!, :symbolize_keys!, :to_options!, :transform_keys! ]
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Map
(also: #store)
Set the value of a given key.
-
#clear ⇒ Map
Remove all elements from this map.
-
#delete(key) ⇒ Map
Delete one key from the map.
-
#merge!(hash) ⇒ Map
(also: #update)
Update a collection of keys and values given by a hash.
-
#replace(hash) ⇒ Map
Replace the entire contents of this map with a new one.
Methods included from Collection
#column_name, #initialize, #inspect, #loaded!, #loaded?, #persisted!
Instance Method Details
#[]=(key, value) ⇒ Map Also known as: store
Set the value of a given key
457 458 459 460 461 |
# File 'lib/cequel/record/collection.rb', line 457 def []=(key, value) key = cast_key(key) updater.map_update(column_name, key => value) to_modify { super } end |
#clear ⇒ Map
Remove all elements from this map. Equivalent to deleting the column value from the row in CQL
470 471 472 473 |
# File 'lib/cequel/record/collection.rb', line 470 def clear deleter.delete_columns(column_name) to_modify { super } end |
#delete(key) ⇒ Map
Delete one key from the map
481 482 483 484 485 |
# File 'lib/cequel/record/collection.rb', line 481 def delete(key) key = cast_key(key) deleter.map_remove(column_name, key) to_modify { super } end |
#merge!(hash) ⇒ Map Also known as: update
Update a collection of keys and values given by a hash
493 494 495 496 497 |
# File 'lib/cequel/record/collection.rb', line 493 def merge!(hash) hash = cast_collection(hash) updater.map_update(column_name, hash) to_modify { super } end |
#replace(hash) ⇒ Map
Replace the entire contents of this map with a new one
506 507 508 509 510 |
# File 'lib/cequel/record/collection.rb', line 506 def replace(hash) hash = cast_collection(hash) updater.set(column_name => hash) to_modify { super } end |