Module: Cocina::Models

Defined in:
lib/cocina/models.rb,
lib/cocina/models/dro.rb,
lib/cocina/models/file.rb,
lib/cocina/models/druid.rb,
lib/cocina/models/event.rb,
lib/cocina/models/title.rb,
lib/cocina/models/vocab.rb,
lib/cocina/models/access.rb,
lib/cocina/models/source.rb,
lib/cocina/models/embargo.rb,
lib/cocina/models/version.rb,
lib/cocina/models/file_set.rb,
lib/cocina/models/language.rb,
lib/cocina/models/sequence.rb,
lib/cocina/models/standard.rb,
lib/cocina/models/checkable.rb,
lib/cocina/models/source_id.rb,
lib/cocina/models/validator.rb,
lib/cocina/models/applies_to.rb,
lib/cocina/models/collection.rb,
lib/cocina/models/dro_access.rb,
lib/cocina/models/geographic.rb,
lib/cocina/models/access_role.rb,
lib/cocina/models/contributor.rb,
lib/cocina/models/dark_access.rb,
lib/cocina/models/description.rb,
lib/cocina/models/file_access.rb,
lib/cocina/models/release_tag.rb,
lib/cocina/models/request_dro.rb,
lib/cocina/models/admin_policy.rb,
lib/cocina/models/catalog_link.rb,
lib/cocina/models/presentation.rb,
lib/cocina/models/request_file.rb,
lib/cocina/models/world_access.rb,
lib/cocina/models/administrative.rb,
lib/cocina/models/catkey_barcode.rb,
lib/cocina/models/dro_structural.rb,
lib/cocina/models/identification.rb,
lib/cocina/models/message_digest.rb,
lib/cocina/models/stanford_access.rb,
lib/cocina/models/business_barcode.rb,
lib/cocina/models/related_resource.rb,
lib/cocina/models/request_file_set.rb,
lib/cocina/models/standard_barcode.rb,
lib/cocina/models/collection_access.rb,
lib/cocina/models/descriptive_value.rb,
lib/cocina/models/access_role_member.rb,
lib/cocina/models/request_collection.rb,
lib/cocina/models/file_administrative.rb,
lib/cocina/models/file_set_structural.rb,
lib/cocina/models/citation_only_access.rb,
lib/cocina/models/lane_medical_barcode.rb,
lib/cocina/models/request_admin_policy.rb,
lib/cocina/models/location_based_access.rb,
lib/cocina/models/request_dro_structural.rb,
lib/cocina/models/request_identification.rb,
lib/cocina/models/descriptive_basic_value.rb,
lib/cocina/models/collection_identification.rb,
lib/cocina/models/descriptive_grouped_value.rb,
lib/cocina/models/descriptive_admin_metadata.rb,
lib/cocina/models/descriptive_parallel_event.rb,
lib/cocina/models/descriptive_parallel_value.rb,
lib/cocina/models/descriptive_value_language.rb,
lib/cocina/models/admin_policy_administrative.rb,
lib/cocina/models/admin_policy_default_access.rb,
lib/cocina/models/descriptive_access_metadata.rb,
lib/cocina/models/request_file_set_structural.rb,
lib/cocina/models/descriptive_structured_value.rb,
lib/cocina/models/location_based_download_access.rb,
lib/cocina/models/descriptive_geographic_metadata.rb,
lib/cocina/models/descriptive_parallel_contributor.rb,
lib/cocina/models/controlled_digital_lending_access.rb

Overview

Provides Ruby objects for the repository and serializing them to/from JSON.

Defined Under Namespace

Modules: Checkable, Types Classes: Access, AccessRole, AccessRoleMember, AdminPolicy, AdminPolicyAdministrative, AdminPolicyDefaultAccess, Administrative, AppliesTo, CatalogLink, CitationOnlyAccess, Collection, CollectionAccess, CollectionIdentification, Contributor, ControlledDigitalLendingAccess, DRO, DROAccess, DROStructural, DarkAccess, Description, DescriptiveAccessMetadata, DescriptiveAdminMetadata, DescriptiveBasicValue, DescriptiveGeographicMetadata, DescriptiveGroupedValue, DescriptiveParallelContributor, DescriptiveParallelEvent, DescriptiveParallelValue, DescriptiveStructuredValue, DescriptiveValue, DescriptiveValueLanguage, Embargo, Error, Event, File, FileAccess, FileAdministrative, FileSet, FileSetStructural, Geographic, Identification, Language, LocationBasedAccess, LocationBasedDownloadAccess, MessageDigest, Presentation, RelatedResource, ReleaseTag, RequestAdminPolicy, RequestCollection, RequestDRO, RequestDROStructural, RequestFile, RequestFileSet, RequestFileSetStructural, RequestIdentification, Sequence, Source, Standard, StanfordAccess, Struct, Title, UnknownTypeError, ValidationError, Validator, Vocab, WorldAccess

Constant Summary collapse

Druid =
Types::String.constrained(
  format: /^druid:[b-df-hjkmnp-tv-z]{2}[0-9]{3}[b-df-hjkmnp-tv-z]{2}[0-9]{4}$/i
)
VERSION =
'0.60.0'
SourceId =
Types::String.constrained(
  format: /^.+:.+$/i
)
CatkeyBarcode =
Types::String.constrained(
  format: /^[0-9]+-[0-9]+$/i
)
BusinessBarcode =
Types::String.constrained(
  format: /^2050[0-9]{7}$/i
)
StandardBarcode =
Types::String.constrained(
  format: /^36105[0-9]{9}$/i
)
LaneMedicalBarcode =
Types::String.constrained(
  format: /^245[0-9]{8}$/i
)

Class Method Summary collapse

Class Method Details

.build(dyn, validate: true) ⇒ DRO, ...



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cocina/models.rb', line 72

def self.build(dyn, validate: true)
  clazz = case dyn.fetch('type')
          when *DRO::TYPES
            DRO
          when *Collection::TYPES
            Collection
          when *AdminPolicy::TYPES
            AdminPolicy
          else
            raise UnknownTypeError, "Unknown type: '#{dyn.fetch('type')}'"
          end
  clazz.new(dyn, false, validate)
end

.build_request(dyn, validate: true) ⇒ RequestDRO, ...



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cocina/models.rb', line 92

def self.build_request(dyn, validate: true)
  clazz = case dyn.fetch('type')
          when *DRO::TYPES
            RequestDRO
          when *Collection::TYPES
            RequestCollection
          when *AdminPolicy::TYPES
            RequestAdminPolicy
          else
            raise UnknownTypeError, "Unknown type: '#{dyn.fetch('type')}'"
          end
  clazz.new(dyn, false, validate)
end