Module: Ecoportal::API::Common::Content::CollectionModel::Mutation::Delete

Defined in:
lib/ecoportal/api/common/content/collection_model/mutation/delete.rb

Instance Method Summary collapse

Instance Method Details

#delete!(value) ⇒ Object

Deletes value from this CollectionModel instance.

Parameters:

  • value (String, Hash, Ecoportal::API::Common::Content::DoubleModel)
    • When used as String, the key value (i.e. id value) is expected.
    • When used as Hash, it should be the doc of the target element.
    • When used as DoubleModel, it should be the specific object to be deleted.


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ecoportal/api/common/content/collection_model/mutation/delete.rb', line 24

def delete!(value)
  unless value.is_a?(Hash) || value.is_a?(Content::DoubleModel) || value.is_a?(String)
    msg = 'Content::DoubleModel or Hash doc required'
    raise ArgumentError, msg
  end

  return unless (item = self[value])

  _doc_delete(item.doc)
  @indexed = false
  _items.delete(item)
end