Class: Pubid::Ieee::Identifiers::SupplementIdentifier

Inherits:
Pubid::Ieee::Identifier show all
Defined in:
lib/pubid/ieee/identifiers/supplement_identifier.rb

Overview

Identifier class for supplement identifiers (amendments, corrigenda, interpretations, etc.) Supplements modify or add to a base document

Instance Attribute Summary

Attributes inherited from Pubid::Ieee::Identifier

#code_obj, #draft_obj

Instance Method Summary collapse

Methods inherited from Pubid::Ieee::Identifier

additional_identifier_classes, #draft, #draft_month, #exclude, from_hash, #initialize, #mr_number_with_part, #mr_publisher, #mr_type, #mr_year, parse, parse_single

Methods inherited from Pubid::Identifier

apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, #exclude, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_languages, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_mr_string, #to_s, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Ieee::Identifier

Instance Method Details

#codeObject

Delegate code to base if not overridden



17
18
19
# File 'lib/pubid/ieee/identifiers/supplement_identifier.rb', line 17

def code
  base&.code
end

#publisherObject

Delegate publisher to base



12
13
14
# File 'lib/pubid/ieee/identifiers/supplement_identifier.rb', line 12

def publisher
  base&.publisher
end

#to_hash(*args) ⇒ Object

publisher is a pure delegation to base, so it must never be serialized independently on the wrapper. lutaml's default-tracking otherwise emits it asymmetrically — omitted on the parse path (the wrapper's own attribute is never assigned) but present after from_hash (deserialization assigns it) — which breaks the canonical to_hash round-trip for a supplement whose base carries a non-default publisher (e.g. an ANSI/ISO corrigendum). The truth lives in base.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pubid/ieee/identifiers/supplement_identifier.rb', line 28

def to_hash(*args)
  hash = super
  if hash.is_a?(::Hash)
    # `publisher` and `code` are delegated to `base`; never serialize
    # them on the wrapper (they'd duplicate base.publisher/base.number
    # and, for publisher, desync across parse vs from_hash).
    hash.delete("publisher")
    hash.delete("code")
  end
  hash
end