Class: Cocina::Models::Vocabulary

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/vocabulary.rb

Direct Known Subclasses

FileSetType, ObjectType

Class Method Summary collapse

Class Method Details

.[](property) ⇒ String

Returns the URI for the term ‘property` in this vocabulary.

Parameters:

  • property (#to_sym)

Returns:

  • (String)


34
35
36
# File 'lib/cocina/models/vocabulary.rb', line 34

def self.[](property)
  properties[property.to_sym]
end

.create(uri) ⇒ Object

Disabled this cop because we want @@uri to be inheritable. rubocop:disable Style/ClassVars



9
10
11
12
# File 'lib/cocina/models/vocabulary.rb', line 9

def self.create(uri)
  @@uri = uri
  self
end

.propertiesObject



25
26
27
# File 'lib/cocina/models/vocabulary.rb', line 25

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

.property(name, method_name: name.to_s.underscore.to_sym) ⇒ Object



19
20
21
22
23
# File 'lib/cocina/models/vocabulary.rb', line 19

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

.to_sObject

rubocop:enable Style/ClassVars



15
16
17
# File 'lib/cocina/models/vocabulary.rb', line 15

def self.to_s
  @@uri
end