Module: Relaton::Index::IdNumber
Overview
Shared narrowing/sort key for structured (pubid) index ids. Type uses it for binary-search narrowing; FileIO uses it to sort the index and detect sortedness. The two MUST agree, so the rule lives in one place.
Instance Method Summary collapse
-
#get_id_number(id) ⇒ Object
One-level narrowing key: a supplement/amendment is filed under its immediate parent's number, everything else under its own number.
- #id_base(id) ⇒ Object
Instance Method Details
#get_id_number(id) ⇒ Object
One-level narrowing key: a supplement/amendment is filed under its immediate parent's number, everything else under its own number.
Pubid 2.x exposes the parent via .base_identifier (the LutaML
Pubid::Iso::Identifiers::* classes that relaton loads at runtime). A
standalone require "pubid-iso" can instead surface the legacy
Pubid::Iso::Identifier::* classes, which use .base; we accept either
so the key is stable in both load orders. The wrong accessor silently
falls through to the row's own number and breaks bsearch narrowing.
16 17 18 19 |
# File 'lib/relaton/index/id_number.rb', line 16 def get_id_number(id) base = id_base(id) ((base && base.number) || id.number).to_s end |
#id_base(id) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/relaton/index/id_number.rb', line 21 def id_base(id) if id.respond_to?(:base_identifier) && id.base_identifier id.base_identifier elsif id.respond_to?(:base) && id.base id.base end end |