Class: Glossarist::V3::Citation
- Inherits:
-
Citation
- Object
- Lutaml::Model::Serializable
- Citation
- Glossarist::V3::Citation
show all
- Defined in:
- lib/glossarist/v3/citation.rb
Instance Method Summary
collapse
Methods inherited from Citation
#label, #locality_from_yaml, #locality_to_yaml
Instance Method Details
#ref_from_yaml(model, value) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/glossarist/v3/citation.rb', line 10
def ref_from_yaml(model, value)
case value
when Hash
model.ref = Ref.new(value.transform_keys(&:to_sym))
when String
model.ref = Ref.new(source: value)
end
end
|
#ref_to_yaml(model, doc) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/glossarist/v3/citation.rb', line 19
def ref_to_yaml(model, doc)
return unless model.ref
attrs = {}
attrs["source"] = model.ref.source if model.ref.source
attrs["id"] = model.ref.id if model.ref.id
attrs["version"] = model.ref.version if model.ref.version
doc["ref"] = attrs.empty? ? nil : attrs
end
|