Class: Observation

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Citations, Shared::Confidences, Shared::DataAttributes, Shared::Depictions, Shared::Identifiers, Shared::IsData, Shared::Notes, Shared::Tags
Defined in:
app/models/observation.rb

Direct Known Subclasses

Continuous, PresenceAbsence, Qualitative, Sample

Defined Under Namespace

Classes: Continuous, PresenceAbsence, Qualitative, Sample

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Instance Attribute Details

- (Object) observation_object_global_id

Returns the value of attribute observation_object_global_id



12
13
14
# File 'app/models/observation.rb', line 12

def observation_object_global_id
  @observation_object_global_id
end

Class Method Details

+ (Object) human_name



24
25
26
# File 'app/models/observation.rb', line 24

def self.human_name
  'YAY'
end

Instance Method Details

- (Object) convert_observation_object_global_id (protected)



58
59
60
# File 'app/models/observation.rb', line 58

def convert_observation_object_global_id
  set_observation_object_id(GlobalID::Locator.locate(observation_object_global_id)) if observation_object_global_id 
end

- (Object) observation_object



28
29
30
# File 'app/models/observation.rb', line 28

def observation_object
  [otu, collection_object].compact.first
end

- (Object) otu_or_collection_object_set (protected)



62
63
64
65
66
# File 'app/models/observation.rb', line 62

def otu_or_collection_object_set
  if otu_id.blank? && collection_object_id.blank? && otu.blank? && collection_object.blank?
    errors.add(:base, 'observations must reference an Otu or collection object')
  end
end

- (Object) set_observation_object_id(object)



37
38
39
40
41
42
43
44
45
46
# File 'app/models/observation.rb', line 37

def set_observation_object_id(object)
  case object.metamorphosize.class.name
  when 'Otu'
    write_attribute(:otu_id, object.id)
  when 'CollectionObject'
    write_attribute(:collection_object_id, object.id)
  else
    return false
  end 
end