Class: Pubid::Ogc::Identifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Ogc::Identifier
- Defined in:
- lib/pubid/ogc/identifier.rb
Overview
Base class for every OGC identifier AND the flavor's parse/create entry point. There is a single concrete type (Identifiers::Document), so this base mostly exists to hold the shared attributes and the polymorphic serialization mapping.
Direct Known Subclasses
Constant Summary collapse
- OGC_TYPE_MAP =
Polymorphic type map for lutaml::Model key_value (de)serialization: maps the concrete class's polymorphic_name to its class name so a stored hash rebuilds the correct identifier type via from_hash.
{ "pubid:ogc:document" => "Pubid::Ogc::Identifiers::Document", }.freeze
- PUBLISHER =
Publisher is always "OGC". A plain constant (not a
publishermethod) so it doesn't shadow the inherited lutamlpublisherattribute, which would otherwise fail serialization type validation. "OGC"
Instance Attribute Summary collapse
-
#with_publisher ⇒ Object
readonly
Returns the value of attribute with_publisher.
Class Method Summary collapse
-
.parse(identifier) ⇒ Identifier
Parse an OGC identifier string into an identifier object.
Instance Method Summary collapse
-
#render(format: :human, with_publisher: false, **opts) ⇒ Object
Capture the with_publisher flag on EVERY render call (default false), so it can never leak across calls: a bare render/to_s always renders without the publisher token regardless of a prior with_publisher: true.
-
#to_s(**opts) ⇒ Object
Basic string representation.
Methods inherited from 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?, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Attribute Details
#with_publisher ⇒ Object (readonly)
Returns the value of attribute with_publisher.
38 39 40 |
# File 'lib/pubid/ogc/identifier.rb', line 38 def with_publisher @with_publisher end |
Class Method Details
.parse(identifier) ⇒ Identifier
Parse an OGC identifier string into an identifier object.
66 67 68 69 70 71 72 73 74 |
# File 'lib/pubid/ogc/identifier.rb', line 66 def self.parse(identifier) if identifier.length > Pubid::MAX_INPUT_LENGTH raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE end Builder.build(Parser.parse(identifier)) rescue Parslet::ParseFailed => e raise "Failed to parse OGC identifier '#{identifier}': #{e.}" end |
Instance Method Details
#render(format: :human, with_publisher: false, **opts) ⇒ Object
Capture the with_publisher flag on EVERY render call (default false), so
it can never leak across calls: a bare render/to_s always renders
without the publisher token regardless of a prior with_publisher: true.
The base render only forwards :with_edition to the renderer, so the
flag is threaded via this per-call instance write (the renderer reads
id.with_publisher).
53 54 55 56 |
# File 'lib/pubid/ogc/identifier.rb', line 53 def render(format: :human, with_publisher: false, **opts) @with_publisher = with_publisher super(format: format, **opts) end |
#to_s(**opts) ⇒ Object
Basic string representation. Delegates to the human renderer. The printed OGC id carries no publisher token, so with_publisher defaults to false; pass with_publisher: true to prepend "OGC ".
43 44 45 |
# File 'lib/pubid/ogc/identifier.rb', line 43 def to_s(**opts) render(format: :human, **opts) end |