Class: Glossarist::V3::Citation
- Inherits:
-
Citation
- Object
- Citation
- Glossarist::V3::Citation
- Defined in:
- lib/glossarist/v3/citation.rb
Instance Method Summary collapse
Instance Method Details
#ref_from_yaml(model, value) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/glossarist/v3/citation.rb', line 12 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
21 22 23 24 25 26 27 28 29 |
# File 'lib/glossarist/v3/citation.rb', line 21 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 |