Class: Cuprum::Rails::Commands::FindOne
- Inherits:
-
Cuprum::Rails::Command
- Object
- Collections::Command
- Cuprum::Rails::Command
- Cuprum::Rails::Commands::FindOne
- Includes:
- Collections::Commands::AbstractFindOne
- Defined in:
- lib/cuprum/rails/commands/find_one.rb
Overview
Command for finding one ActiveRecord record by primary key.
Instance Attribute Summary
Attributes inherited from Cuprum::Rails::Command
#collection_name, #member_name, #options, #record_class
Instance Method Summary collapse
-
#call(primary_key: , envelope: false, scope: nil) ⇒ Cuprum::Result<Hash{String, Object}>
Queries the collection for the record with the given primary key.
Methods inherited from Cuprum::Rails::Command
#initialize, #primary_key_name, #primary_key_type, subclass
Constructor Details
This class inherits a constructor from Cuprum::Rails::Command
Instance Method Details
#call(primary_key: , envelope: false, scope: nil) ⇒ Cuprum::Result<Hash{String, Object}>
Queries the collection for the record 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 record in a Hash, using the singular name of the collection as the key.
34 35 36 37 38 |
# File 'lib/cuprum/rails/commands/find_one.rb', line 34 validate_parameters :call do keyword :envelope, Stannum::Constraints::Boolean.new, default: true keyword :primary_key, Object keyword :scope, Cuprum::Rails::Query, optional: true end |