Module: Linzer::Message::Field::IdentifierMethods Private

Included in:
Identifier
Defined in:
lib/linzer/message/field.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Methods mixed into the Identifier class for field name handling.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#itemStarry::Item? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The parsed structured field item.

Returns:

  • (Starry::Item, nil)

    The parsed structured field item



24
25
26
# File 'lib/linzer/message/field.rb', line 24

def item
  @item
end

Instance Method Details

#derived?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if this is a derived component (starts with @).

Returns:

  • (Boolean)

    true if derived (e.g., @method, @path)



28
29
30
# File 'lib/linzer/message/field.rb', line 28

def derived?
  item&.value&.start_with?("@")
end

#initialize(field_name:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the identifier by parsing the field name.

Parameters:

  • field_name (String)

    The component identifier string



18
19
20
21
# File 'lib/linzer/message/field.rb', line 18

def initialize(field_name:)
  @item = Identifier::Parser.parse(field_name) rescue nil
  super
end

#serializeString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Serializes the component identifier.

Returns:

  • (String)

    The serialized identifier (e.g., ‘“@method”’)

Raises:

  • (Error)

    If the component identifier is invalid



35
36
37
38
# File 'lib/linzer/message/field.rb', line 35

def serialize
  raise Error, "Invalid component identifier: '#{field_name}'!" unless item
  Starry.serialize(@item)
end