Module: Shared::QueryBatchUpdate

Extended by:
ActiveSupport::Concern
Included in:
AssertedDistribution, BiologicalAssociation, CollectingEvent, CollectionObject, FieldOccurrence, Otu, Source::Bibtex, TaxonName
Defined in:
app/models/concerns/shared/query_batch_update.rb

Overview

Facilitate batch updates that use a BatchQueryRequest

Instance Method Summary collapse

Instance Method Details

#query_update(params, response = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/concerns/shared/query_batch_update.rb', line 13

def query_update(params, response=nil)
  begin
    update!( params )
    response.updated.push self.id if response
  rescue ActiveRecord::RecordInvalid => e
    return if response.nil?
    response.not_updated.push e.record.id

    response.errors[e.message] = 0 unless response.errors[e.message]

    response.errors[e.message] += 1
  end
end