Class: Pubid::Components::Adoption
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Components::Adoption
- Defined in:
- lib/pubid/components/adoption.rb
Overview
Adoption component — captures the metadata when one identifier adopts another. Originally surfaced as BSI’s AdoptedInternationalStandard / AdoptedEuropeanNorm and CEN-CENELEC’s AdoptedEuropeanNorm; the same shape applies to CSA adoptions and IEEE Adopted-Standard relationships.
Shape (union across BSI, CEN-CENELEC, CSA, IEEE):
-
base: the adopted document (polymorphic Identifier).
-
adopter_publisher: the publisher doing the adopting (BS, EN,
CAN/, CSA, IEEE). -
edition: edition of the adoption (BSI-only).
-
date: adoption date (replaces ad-hoc year attrs).
-
translation_lang: translation language code (BSI-only).
-
translation_upper: upper-case translation marker (BSI-only).
-
translation_suffix_type: “version” or “Translation” (BSI-only).
-
reaffirmation_year: “(R2004)” reaffirmation notation (BSI, CSA).
-
expert_commentary: true when the adoption ships with commentary
(BSI-only). -
expert_commentary_topic: topic of the commentary (BSI-only).
-
publisher_prefix: CSA-specific dash-vs-space prefix.
Render delegates to the base identifier; the adopter’s renderer decides the prefix and any suffix notation (translation, reaffirmation, commentary) by calling adoption.render(context:).
Constant Summary collapse
- IDENTITY_FIELDS =
%i[ base adopter_publisher edition date translation_lang translation_upper translation_suffix_type reaffirmation_year expert_commentary expert_commentary_topic publisher_prefix ].freeze
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #present? ⇒ Boolean
- #render(context: nil) ⇒ Object
- #to_s(**opts) ⇒ Object
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
67 68 69 70 71 |
# File 'lib/pubid/components/adoption.rb', line 67 def ==(other) return false unless other.is_a?(self.class) IDENTITY_FIELDS.all? { |f| public_send(f) == other.public_send(f) } end |
#hash ⇒ Object
75 76 77 |
# File 'lib/pubid/components/adoption.rb', line 75 def hash @hash ||= [self.class, *IDENTITY_FIELDS.map { |f| public_send(f) }].hash end |
#present? ⇒ Boolean
49 50 51 |
# File 'lib/pubid/components/adoption.rb', line 49 def present? IDENTITY_FIELDS.any? { |f| present_value?(public_send(f)) } end |
#render(context: nil) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/pubid/components/adoption.rb', line 53 def render(context: nil) return "" unless base body = base.to_s body += translation_suffix if translation_lang body += reaffirmation_suffix if reaffirmation_year body += commentary_suffix if expert_commentary body end |
#to_s(**opts) ⇒ Object
63 64 65 |
# File 'lib/pubid/components/adoption.rb', line 63 def to_s(**opts) render(context: opts[:context]) end |