Module: Cuprum::Collections::Commands::AbstractFindOne

Includes:
ParameterValidation
Included in:
Basic::Commands::FindOne
Defined in:
lib/cuprum/collections/commands/abstract_find_one.rb

Overview

Abstract implementation of the FindOne command.

Instance Method Summary collapse

Instance Method Details

#call(primary_key:, envelope: false) ⇒ 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.

Parameters:

  • envelope (Boolean) (defaults to: false)

    If true, wraps the result value in a Hash.

  • primary_key (Object)

    The primary key of the requested item.

Returns:

  • (Cuprum::Result<Hash{String, Object}>)

    a result with the requested item.



28
# File 'lib/cuprum/collections/commands/abstract_find_one.rb', line 28

validate :envelope, :boolean, optional: true