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.

Direct Known Subclasses

Bibdata, Bibitem

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



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, 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



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

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