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

#type ⇒ Object

in some cases mehod type is unavailable



11
12
13
# File 'lib/relaton/bib/model/item.rb', line 11

def type
  @type
end

Class Method Details

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



15
16
17
18
19
20
21
22
23
24
# File 'lib/relaton/bib/model/item.rb', line 15

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_version ⇒ Object



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

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