Sha256: 21a831c956ec28afd7554006eff21ba0ea2701fdbd52fb3e60bd792e35234973

Contents?: true

Size: 885 Bytes

Versions: 51

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

module Cocina
  module Models
    class Vocabulary
      # @private
      # Disabled this cop because we want @@uri to be inheritable.
      # rubocop:disable Style/ClassVars
      def self.create(uri)
        @@uri = uri
        self
      end
      # rubocop:enable Style/ClassVars

      def self.to_s
        @@uri
      end

      def self.property(name, method_name: name.to_s.underscore.to_sym)
        uri = [to_s, name].join
        properties[name] = uri
        (class << self; self; end).send(:define_method, method_name) { uri }
      end

      def self.properties
        @properties ||= {}
      end

      ##
      # Returns the URI for the term `property` in this vocabulary.
      #
      # @param  [#to_sym] property
      # @return [String]
      def self.[](property)
        properties[property.to_sym]
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
cocina-models-0.89.0 lib/cocina/models/vocabulary.rb
cocina-models-0.88.0 lib/cocina/models/vocabulary.rb
cocina-models-0.87.1 lib/cocina/models/vocabulary.rb
cocina-models-0.87.0 lib/cocina/models/vocabulary.rb
cocina-models-0.86.0 lib/cocina/models/vocabulary.rb
cocina-models-0.85.0 lib/cocina/models/vocabulary.rb
cocina-models-0.84.5 lib/cocina/models/vocabulary.rb
cocina-models-0.84.4 lib/cocina/models/vocabulary.rb
cocina-models-0.84.3 lib/cocina/models/vocabulary.rb
cocina-models-0.84.2 lib/cocina/models/vocabulary.rb
cocina-models-0.84.1 lib/cocina/models/vocabulary.rb
cocina-models-0.84.0 lib/cocina/models/vocabulary.rb
cocina-models-0.83.0 lib/cocina/models/vocabulary.rb
cocina-models-0.82.0 lib/cocina/models/vocabulary.rb
cocina-models-0.81.0 lib/cocina/models/vocabulary.rb
cocina-models-0.80.0 lib/cocina/models/vocabulary.rb
cocina-models-0.79.0 lib/cocina/models/vocabulary.rb
cocina-models-0.78.0 lib/cocina/models/vocabulary.rb
cocina-models-0.77.0 lib/cocina/models/vocabulary.rb
cocina-models-0.76.0 lib/cocina/models/vocabulary.rb