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.99.1 lib/cocina/models/vocabulary.rb
cocina-models-0.99.0 lib/cocina/models/vocabulary.rb
cocina-models-0.98.1 lib/cocina/models/vocabulary.rb
cocina-models-0.98.0 lib/cocina/models/vocabulary.rb
cocina-models-0.96.0 lib/cocina/models/vocabulary.rb
cocina-models-0.95.1 lib/cocina/models/vocabulary.rb
cocina-models-0.95.0 lib/cocina/models/vocabulary.rb
cocina-models-0.94.2 lib/cocina/models/vocabulary.rb
cocina-models-0.94.1 lib/cocina/models/vocabulary.rb
cocina-models-0.94.0 lib/cocina/models/vocabulary.rb
cocina-models-0.93.1 lib/cocina/models/vocabulary.rb
cocina-models-0.93.0 lib/cocina/models/vocabulary.rb
cocina-models-0.92.0 lib/cocina/models/vocabulary.rb
cocina-models-0.91.4 lib/cocina/models/vocabulary.rb
cocina-models-0.91.3 lib/cocina/models/vocabulary.rb
cocina-models-0.91.2 lib/cocina/models/vocabulary.rb
cocina-models-0.91.1 lib/cocina/models/vocabulary.rb
cocina-models-0.91.0 lib/cocina/models/vocabulary.rb
cocina-models-0.90.0 lib/cocina/models/vocabulary.rb
cocina-models-0.89.1 lib/cocina/models/vocabulary.rb