Module: NCore::UpdateBulk::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

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



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

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

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

Raises:

  • (module_parent::RecordNotFound)


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

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