Class: Cocina::Models::Vocabulary
- Inherits:
-
Object
- Object
- Cocina::Models::Vocabulary
- Defined in:
- lib/cocina/models/vocabulary.rb
Direct Known Subclasses
Class Method Summary collapse
-
.[](property) ⇒ String
Returns the URI for the term ‘property` in this vocabulary.
-
.create(uri) ⇒ Object
Disabled this cop because we want @@uri to be inheritable.
- .properties ⇒ Object
- .property(name, method_name: name.to_s.underscore.to_sym) ⇒ Object
-
.to_s ⇒ Object
rubocop:enable Style/ClassVars.
Class Method Details
.[](property) ⇒ String
Returns the URI for the term ‘property` in this vocabulary.
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 |
.properties ⇒ Object
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_s ⇒ Object
rubocop:enable Style/ClassVars
15 16 17 |
# File 'lib/cocina/models/vocabulary.rb', line 15 def self.to_s @@uri end |