Class: Identifier::Global::Uri
- Inherits:
-
Identifier::Global
- Object
- ActiveRecord::Base
- ApplicationRecord
- Identifier
- Identifier::Global
- Identifier::Global::Uri
- Defined in:
- app/models/identifier/global/uri.rb
Overview
Universal Resource Identifier
Direct Known Subclasses
Defined Under Namespace
Classes: Grscicoll
Constant Summary
Constants included from SoftValidation
SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS
Constants included from Shared::DualAnnotator
Shared::DualAnnotator::ALWAYS_COMMUNITY
Instance Attribute Summary
Attributes inherited from Identifier::Global
Attributes inherited from Identifier
#cached, #cached_numeric_identifier, #identifier, #identifier_object_id, #namespace_id, #project_id, #type
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
Methods inherited from Identifier
#build_cached, #build_cached_numeric_identifier, #is_global?, #is_local?, prototype_identifier, #set_cached, #type_name
Methods included from Shared::IsData
#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar
Methods included from Shared::Labels
Methods included from Housekeeping
#has_polymorphic_relationship?
Methods included from Shared::PolymorphicAnnotator
#annotated_object_is_persisted?
Methods inherited from ApplicationRecord
Instance Method Details
#identifier_is_uri ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/identifier/global/uri.rb', line 8 def identifier_is_uri unless identifier.nil? uris = URI.extract(identifier) if uris.count == 0 errors.add(:identifier, 'No URI detected.') else unless (identifier.length == uris[0].length) and (uris.count == 1) errors.add(:identifier, 'More than a single URI present.') else begin uri = URI(identifier) scheme = uri.scheme.upcase unless URI.scheme_list.keys.include?(scheme) errors.add(:identifier, "#{scheme} is not in the URI schemes list.") end rescue errors.add(:identifier, "Badly formed URI #{identifier} detected.") end end end end end |