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 Cuprum::Collections::Basic::Command

#collection_name, #data, #default_contract, #member_name, #options, #primary_key_name, #primary_key_type

Instance Method Summary collapse

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

#initialize, subclass

Constructor Details

This class inherits a constructor from Cuprum::Collections::Basic::Command

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) (defaults to: )

    The primary key of the requested item.

Returns:

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

    a result with the destroyed item.



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

validate_parameters :call do
  keyword :primary_key, Object
end