Class: Relaton::Bib::Formattedref
- Inherits:
-
LocalizedMarkedUpString
- Object
- Lutaml::Model::Serializable
- LocalizedStringAttrs
- LocalizedMarkedUpString
- Relaton::Bib::Formattedref
- Defined in:
- lib/relaton/bib/model/formattedref.rb
Class Method Summary collapse
-
.as(format, instance, options = {}) ⇒ Object
Serialize as plain string when only content is present.
- .from_json(value) ⇒ Object
-
.from_yaml(value) ⇒ Object
Handle plain string input from YAML/JSON deserialization.
- .simple_content?(instance, format) ⇒ Boolean
Class Method Details
.as(format, instance, options = {}) ⇒ Object
Serialize as plain string when only content is present
29 30 31 32 33 |
# File 'lib/relaton/bib/model/formattedref.rb', line 29 def self.as(format, instance, = {}) return instance.content if simple_content?(instance, format) super end |
.from_json(value) ⇒ Object
22 23 24 25 26 |
# File 'lib/relaton/bib/model/formattedref.rb', line 22 def self.from_json(value) return new(content: value) if value.is_a?(String) super end |
.from_yaml(value) ⇒ Object
Handle plain string input from YAML/JSON deserialization
16 17 18 19 20 |
# File 'lib/relaton/bib/model/formattedref.rb', line 16 def self.from_yaml(value) return new(content: value) if value.is_a?(String) super end |
.simple_content?(instance, format) ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/relaton/bib/model/formattedref.rb', line 35 def self.simple_content?(instance, format) return false if format == :xml instance.format.nil? && instance.language.nil? && instance.script.nil? && instance.locale.nil? end |