Class: Cuprum::Collections::Basic::Commands::FindOne
- Inherits:
-
Cuprum::Collections::Basic::Command
- Object
- Cuprum::Command
- Command
- Cuprum::Collections::Basic::Command
- Cuprum::Collections::Basic::Commands::FindOne
- Includes:
- Commands::AbstractFindOne
- Defined in:
- lib/cuprum/collections/basic/commands/find_one.rb
Overview
Command for finding one collection item by primary key.
Instance Attribute Summary
Attributes inherited from Cuprum::Collections::Basic::Command
#collection_name, #data, #default_contract, #member_name, #options, #primary_key_name, #primary_key_type
Instance Method Summary collapse
-
#call(primary_key: , envelope: false, scope: nil) ⇒ Cuprum::Result<Hash{String, Object}>
Queries the collection for the item with the given primary key.
Methods inherited from Cuprum::Collections::Basic::Command
Constructor Details
This class inherits a constructor from Cuprum::Collections::Basic::Command
Instance Method Details
#call(primary_key: , envelope: false, scope: nil) ⇒ Cuprum::Result<Hash{String, Object}>
Queries the collection for the item with the given primary key.
The command will find and return the entity with the given primary key. If the entity is not found, the command will fail and return a NotFound error.
When the :envelope option is true, the command wraps the item in a Hash, using the singular name of the collection as the key.
31 32 33 34 35 |
# File 'lib/cuprum/collections/basic/commands/find_one.rb', line 31 validate_parameters :call do keyword :envelope, Stannum::Constraints::Boolean.new, default: true keyword :primary_key, Object keyword :scope, Cuprum::Collections::Basic::Query, optional: true end |