Class: Glossarist::Designation::Base
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Glossarist::Designation::Base
show all
- Defined in:
- lib/glossarist/designation/base.rb
Class Method Summary
collapse
Class Method Details
.infer_designation_type(hash) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/glossarist/designation/base.rb', line 54
def self.infer_designation_type(hash)
if hash["abbreviation_type"]
"abbreviation"
elsif hash["international"]
"symbol"
else
"expression"
end
end
|
.of_yaml(hash, options = {}) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/glossarist/designation/base.rb', line 35
def self.of_yaml(hash, options = {})
type = hash["type"]
if type.nil? || /\w/ !~ type
type = infer_designation_type(hash)
hash["type"] = type
end
if self == Base
SERIALIZED_TYPES[type].of_yaml(hash)
else
unless SERIALIZED_TYPES[self] == type
raise ArgumentError, "unexpected designation type: #{type}"
end
super
end
end
|