Class: Cuprum::Collections::Commands::Upsert
- Inherits:
-
Cuprum::Command
- Object
- Cuprum::Command
- Cuprum::Collections::Commands::Upsert
- Defined in:
- lib/cuprum/collections/commands/upsert.rb
Overview
Command for creating or updating an entity from an attributes Hash.
Instance Attribute Summary collapse
-
#attribute_names ⇒ Array<String>
readonly
The names of the attributes used to find the unique entity.
-
#collection ⇒ Object
readonly
The collection used to store the entity.
-
#contract ⇒ Stannum::Constraint
readonly
The constraint used to validate the entity.
Instance Method Summary collapse
-
#initialize(collection:, attribute_names: 'id', contract: nil) ⇒ Upsert
constructor
A new instance of Upsert.
Constructor Details
#initialize(collection:, attribute_names: 'id', contract: nil) ⇒ Upsert
Returns a new instance of Upsert.
81 82 83 84 85 86 87 |
# File 'lib/cuprum/collections/commands/upsert.rb', line 81 def initialize(collection:, attribute_names: 'id', contract: nil) super() @attribute_names = normalize_attribute_names(attribute_names) @collection = collection @contract = contract end |
Instance Attribute Details
#attribute_names ⇒ Array<String> (readonly)
Returns the names of the attributes used to find the unique entity.
91 92 93 |
# File 'lib/cuprum/collections/commands/upsert.rb', line 91 def attribute_names @attribute_names end |
#collection ⇒ Object (readonly)
Returns the collection used to store the entity.
94 95 96 |
# File 'lib/cuprum/collections/commands/upsert.rb', line 94 def collection @collection end |
#contract ⇒ Stannum::Constraint (readonly)
Returns the constraint used to validate the entity.
97 98 99 |
# File 'lib/cuprum/collections/commands/upsert.rb', line 97 def contract @contract end |