Class: Cequel::Record::Set
- Inherits:
-
Set
- Object
- Set
- Cequel::Record::Set
- Includes:
- Collection
- Defined in:
- lib/cequel/record/collection.rb
Overview
The value of a set column in a Cequel::Record instance. Contains an unordered, unique set of elements. Encapsulates and behaves like the ‘Set` type from the standard library.
Constant Summary collapse
- NON_ATOMIC_MUTATORS =
These methods are not implemented because they cannot be expressed as a single CQL3 write operation.
[ :add?, :collect!, :delete?, :delete_if, :flatten!, :keep_if, :map!, :reject!, :select! ]
Instance Method Summary collapse
-
#add(object) ⇒ Set
(also: #<<)
Add an element to the set.
-
#clear ⇒ Set
Remove everything from the set.
-
#delete(object) ⇒ Set
Remove a single element from the set.
-
#replace(set) ⇒ Set
Replace the entire contents of this set with another set.
Methods included from Collection
#column_name, #initialize, #inspect, #loaded!, #loaded?, #persisted!
Methods included from Util::Forwardable
Instance Method Details
#add(object) ⇒ Set Also known as: <<
Add an element to the set
394 395 396 397 398 |
# File 'lib/cequel/record/collection.rb', line 394 def add(object) object = cast_element(object) to_update { updater.set_add(column_name, object) } to_modify { super } end |
#clear ⇒ Set
Remove everything from the set. Equivalent to deleting the collection column from the record’s row.
407 408 409 410 |
# File 'lib/cequel/record/collection.rb', line 407 def clear to_update { deleter.delete_columns(column_name) } to_modify { super } end |
#delete(object) ⇒ Set
Remove a single element from the set
418 419 420 421 422 |
# File 'lib/cequel/record/collection.rb', line 418 def delete(object) object = cast_element(object) to_update { updater.set_remove(column_name, object) } to_modify { super } end |
#replace(set) ⇒ Set
Replace the entire contents of this set with another set
430 431 432 433 434 |
# File 'lib/cequel/record/collection.rb', line 430 def replace(set) set = cast_collection(set) to_update { updater.set(column_name => set) } to_modify { super } end |