Module: Shared::IsDwcOccurrence

Extended by:
ActiveSupport::Concern
Included in:
AssertedDistribution, CollectionObject
Defined in:
app/models/concerns/shared/is_dwc_occurrence.rb

Overview

Shared code for data classes that can be serialized as DwcOccurrence records

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) dwc_occurrence_attributes



29
30
31
32
33
34
35
36
37
38
# File 'app/models/concerns/shared/is_dwc_occurrence.rb', line 29

def dwc_occurrence_attributes
  a = {}
  self.class::DWC_OCCURRENCE_MAP.each do |k,v|
    a[k] = send(v)
  end
  a[:project_id] = project_id
  a[:created_by_id] = created_by_id
  a[:updated_by_id] = updated_by_id
  a
end

- (Object) get_dwc_occurrence



40
41
42
43
44
45
46
# File 'app/models/concerns/shared/is_dwc_occurrence.rb', line 40

def get_dwc_occurrence
  if dwc_occurrence_persisted?
    dwc_occurrence
  else
    set_dwc_occurrence
  end
end

- (DwcOccurrence) set_dwc_occurrence

Returns TODO: !! Currently uses updater_id of this record, need to change that to be user-definable

Returns:

  • (DwcOccurrence)

    TODO: !! Currently uses updater_id of this record, need to change that to be user-definable



20
21
22
23
24
25
26
27
# File 'app/models/concerns/shared/is_dwc_occurrence.rb', line 20

def set_dwc_occurrence
  if dwc_occurrence_persisted?
    dwc_occurrence.update(dwc_occurrence_attributes)
  else
    create_dwc_occurrence!(dwc_occurrence_attributes)
  end
  dwc_occurrence
end