Class: Relaton::Iso::Type::Pubid

Inherits:
Lutaml::Model::Type::Value
  • Object
show all
Defined in:
lib/relaton/iso/type/pubid.rb

Overview

Lutaml-model attribute type that preserves ‘Pubid::Iso::Identifier::Base` instances on the way in and stringifies them on the way out.

The default ‘:string` type calls `.to_s` during `cast`, which loses the parsed structure and forces `Docidentifier#content=` to re-parse the human-readable form. That round-trip can render dual-type strings (e.g. `“ISO/IS TR 17”` from a TR pubid with stage 60.60) that the pubid-iso parslet grammar can’t capture cleanly, producing ‘Duplicate subtrees while merging result of ROOT` warnings.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cast(value, _options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/relaton/iso/type/pubid.rb', line 14

def self.cast(value, _options = {})
  return nil if value.nil?
  return value if Lutaml::Model::Utils.uninitialized?(value)

  value
end

.default_xsd_typeObject



44
45
46
# File 'lib/relaton/iso/type/pubid.rb', line 44

def self.default_xsd_type
  "xs:string"
end

.serialize(value) ⇒ Object



21
22
23
24
25
26
# File 'lib/relaton/iso/type/pubid.rb', line 21

def self.serialize(value)
  return nil if value.nil?
  return value if Lutaml::Model::Utils.uninitialized?(value)

  value.to_s
end

Instance Method Details

#to_json(*_args) ⇒ Object



40
41
42
# File 'lib/relaton/iso/type/pubid.rb', line 40

def to_json(*_args)
  value.to_s
end

#to_sObject



28
29
30
# File 'lib/relaton/iso/type/pubid.rb', line 28

def to_s
  value.to_s
end

#to_xmlObject



36
37
38
# File 'lib/relaton/iso/type/pubid.rb', line 36

def to_xml
  value.to_s
end

#to_yamlObject



32
33
34
# File 'lib/relaton/iso/type/pubid.rb', line 32

def to_yaml
  value.to_s
end