Class: Relaton::Bib::Item

Inherits:
Lutaml::Model::Serializable
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NamespaceHelper

included

Instance Attribute Details

#typeObject

in some cases mehod type is unavailable



63
64
65
# File 'lib/relaton/bib/model/item.rb', line 63

def type
  @type
end

Class Method Details

.from_xml(xml, options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/relaton/bib/model/item.rb', line 67

def self.from_xml(xml, options = {})
  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, options)
end

Instance Method Details

#get_schema_versionObject



93
# File 'lib/relaton/bib/model/item.rb', line 93

def get_schema_version = Relaton.schema_versions["relaton-models"]