Class: Cuprum::Rails::Commands::DestroyOne

Inherits:
Cuprum::Rails::Command show all
Defined in:
lib/cuprum/rails/commands/destroy_one.rb

Overview

Command for destroying an 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

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: ) ⇒ Cuprum::Result<Hash{String, Object}>

Finds and destroys the record with the given primary key.

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

Parameters:

  • primary_key (Object) (defaults to: )

    The primary key of the requested record.

Returns:

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

    a result with the destroyed record.



22
23
24
# File 'lib/cuprum/rails/commands/destroy_one.rb', line 22

validate_parameters :call do
  keyword :primary_key, Object
end