Class: Cuprum::Collections::Basic::Commands::InsertOne

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

Overview

Command for inserting an entity into the collection.

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(entity: ) ⇒ Cuprum::Result<Hash>

Inserts the entity into the collection.

If the collection already includes an entity with the same primary key, #call will fail and the collection will not be updated.

Parameters:

  • entity (Hash) (defaults to: )

    The collection entity to persist.

Returns:

  • (Cuprum::Result<Hash>)

    the persisted entity.



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

validate_parameters :call do
  keyword :entity,
    Stannum::Constraints::Types::HashWithStringKeys.new
end