Class: Cuprum::Rails::Commands::FindMany
- Inherits:
-
Cuprum::Rails::Command
- Object
- Collections::Command
- Cuprum::Rails::Command
- Cuprum::Rails::Commands::FindMany
- Includes:
- Collections::Commands::AbstractFindMany
- Defined in:
- lib/cuprum/rails/commands/find_many.rb
Overview
Command for finding multiple ActiveRecord records 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_keys: , allow_partial: false, envelope: false, scope: nil) ⇒ Cuprum::Result<Array<ActiveRecord>>
Queries the collection for the records with the given primary keys.
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_keys: , allow_partial: false, envelope: false, scope: nil) ⇒ Cuprum::Result<Array<ActiveRecord>>
Queries the collection for the records with the given primary keys.
The command will find and return the entities with the given primary keys. If any of the records are not found, the command will fail and return a NotFound error. If the :allow_partial option is set, the command will return a partial result unless none of the requested records are found.
When the :envelope option is true, the command wraps the records in a Hash, using the name of the collection as the key.
37 38 39 40 41 42 |
# File 'lib/cuprum/rails/commands/find_many.rb', line 37 validate_parameters :call do keyword :allow_partial, Stannum::Constraints::Boolean.new, default: true keyword :envelope, Stannum::Constraints::Boolean.new, default: true keyword :primary_keys, Array keyword :scope, Cuprum::Rails::Query, optional: true end |