lib/cocina/models.rb in cocina-models-0.83.0 vs lib/cocina/models.rb in cocina-models-0.84.0

- old
+ new

@@ -38,11 +38,11 @@ loader = Zeitwerk::Loader.new loader.inflector = CocinaModelsInflector.new loader.push_dir(File.absolute_path("#{__FILE__}/../..")) loader.ignore("#{__dir__}/rspec.rb") -loader.ignore("#{__dir__}/rspec/**/*.rb") +loader.ignore("#{__dir__}/rspec") loader.setup module Cocina # Provides Ruby objects for the repository and serializing them to/from JSON. module Models @@ -151,7 +151,14 @@ dyn.with_indifferent_access.fetch('type') rescue KeyError raise ValidationError, 'Type field not found' end private_class_method :type_for + + def self.druid_regex + @druid_regex ||= begin + str = Openapi3Parser.load_file('openapi.yml').components.schemas['Druid'].pattern + Regexp.new(str) + end + end end end