Class: Relaton::Bib::Item
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Relaton::Bib::Item
- Includes:
- NamespaceHelper
- Defined in:
- lib/relaton/bib/model/item.rb
Overview
Item class repesents bibliographic item metadata. Used for YAML/JSON parsing and as the XML dispatch entry point.
Instance Attribute Summary collapse
-
#type ⇒ Object
in some cases mehod type is unavailable.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from NamespaceHelper
Instance Attribute Details
#type ⇒ Object
in some cases mehod type is unavailable
56 57 58 |
# File 'lib/relaton/bib/model/item.rb', line 56 def type @type end |
Class Method Details
.from_xml(xml, options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/relaton/bib/model/item.rb', line 60 def self.from_xml(xml, = {}) return super unless self == namespace::Item # lutaml-model has no built-in dispatch on root element name # (polymorphic_map only works on attribute discriminators), so we # peek at the root tag with Nokogiri and forward to the right class. root_name = Nokogiri::XML(xml.to_s).root&.name klass = root_name == "bibdata" ? namespace::Bibdata : namespace::Bibitem klass.from_xml(xml, ) end |
Instance Method Details
#get_schema_version ⇒ Object
86 |
# File 'lib/relaton/bib/model/item.rb', line 86 def get_schema_version = Relaton.schema_versions["relaton-models"] |