Module: NCore::DeleteBulk::ClassMethods

Defined in:
lib/ncore/methods/delete_bulk.rb

Instance Method Summary collapse

Instance Method Details

#bulk_delete(ids, params = {}) ⇒ Object



18
19
20
21
22
# File 'lib/ncore/methods/delete_bulk.rb', line 18

def bulk_delete(ids, params={})
  bulk_delete!(ids, params)
rescue module_parent::RecordNotFound, module_parent::BulkActionError
  false
end

#bulk_delete!(ids, params = {}) ⇒ Object

Raises:

  • (module_parent::RecordNotFound)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ncore/methods/delete_bulk.rb', line 6

def bulk_delete!(ids, params={})
  raise(module_parent::RecordNotFound, "ids must not be empty") if ids.blank?
  params[:ids] = ids
  params = parse_request_params(params)
  parsed, _creds = request(:delete, resource_path, params)
  if parsed[:errors].any?
    raise module_parent::BulkActionError, parsed[:errors]
  else
    parsed[:metadata]
  end
end