Class: Cuprum::Collections::Basic::Commands::DestroyOne

Inherits:
Cuprum::Collections::Basic::Command show all
Defined in:
lib/cuprum/collections/basic/commands/destroy_one.rb

Overview

Command for destroying one collection item by primary key.

Instance Attribute Summary

Attributes inherited from CollectionCommand

#collection

Instance Method Summary collapse

Methods inherited from Cuprum::Collections::Basic::Command

#data, #default_contract

Methods inherited from CollectionCommand

#initialize, #name, #primary_key_name, #primary_key_type, #query, #singular_name

Constructor Details

This class inherits a constructor from Cuprum::Collections::CollectionCommand

Instance Method Details

#call(primary_key:) ⇒ Cuprum::Result<Hash{String, Object}>

Finds and destroys the item with the given primary key.

The command will find the entity with the given primary key and remove it from the collection. If the entity is not found, the command will fail and return a NotFound error.

Parameters:

  • primary_key (Object)

    The primary key of the requested item.

Returns:

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

    a result with the destroyed item.



21
# File 'lib/cuprum/collections/basic/commands/destroy_one.rb', line 21

validate :primary_key