Class: Identifier::Global::Uuid

Inherits:
Identifier::Global show all
Defined in:
app/models/identifier/global/uuid.rb

Overview

Universally Unique Identifier

validates :identifier, :format => => /[0-9a-f]{8-[0-9a-f]4-[0-9a-f]4-[0-9a-f]4-[0-9a-f]12/i, :message => 'Invalid UUID.'}

Direct Known Subclasses

Auto, TaxonworksDwcOccurrence

Defined Under Namespace

Classes: Auto, TaxonworksDwcOccurrence

Constant Summary

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary collapse

Attributes inherited from Identifier::Global

#relation

Instance Method Summary collapse

Methods inherited from Identifier::Global

#build_cached, #dwc_occurrences, #is_global?, #sv_resolves?

Methods included from SoftValidation

#clear_soft_validations, #fix_for, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations, #soft_validators

Instance Attribute Details

#is_generatedObject

Returns the value of attribute is_generated.



6
7
8
# File 'app/models/identifier/global/uuid.rb', line 6

def is_generated
  @is_generated
end

Instance Method Details

#generate_uuidObject



12
13
14
# File 'app/models/identifier/global/uuid.rb', line 12

def generate_uuid
  write_attribute(:identifier, SecureRandom.uuid)
end

#using_uuid_classObject



16
17
18
19
20
21
22
23
# File 'app/models/identifier/global/uuid.rb', line 16

def using_uuid_class
  unless identifier.nil?
    /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i =~ identifier
    if $&.nil?
      errors.add(:identifier, "#{identifier} is not a valid UUID.")
    end
  end
end