Class: Kobako::Snippet::Source

Inherits:
Data
  • Object
show all
Defined in:
lib/kobako/snippet/source.rb,
sig/kobako/snippet/source.rbs

Overview

Kobako::Snippet::Source — value object representing a single #preload(code:, name:) entry held by Kobako::Catalog::Snippets.

name is the canonical Symbol identity baked into the loaded IREP's debug_info; backtrace frames originating in this snippet surface as (snippet:Name):line. body is the UTF-8 mruby source detached from the caller's reference at Catalog::Snippets#register time so later mutation of the original String cannot bleed through.

The class is a Data.define subclass — frozen, value-equal, and carries no mutation API. Callers (chiefly Catalog::Snippets) construct instances via keyword form Source.new(name: ..., body: ...). Wire-form construction is the registry's responsibility: as a leaf carrier this Source stays pure and Catalog::Snippets#encode reads its attributes off the outside rather than asking it to self-encode.

Constant Summary collapse

KIND =

The kind field value carried by source snippets in their Frame 3 wire envelope entry (docs/wire-codec.md Invocation channels).

Returns:

  • (String)
"source"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bodyString (readonly)

Returns the value of attribute body.

Returns:

  • (String)


7
8
9
# File 'sig/kobako/snippet/source.rbs', line 7

def body
  @body
end

#nameSymbol (readonly)

Returns the value of attribute name.

Returns:

  • (Symbol)


6
7
8
# File 'sig/kobako/snippet/source.rbs', line 6

def name
  @name
end

Class Method Details

.new(name:, body:) ⇒ Source .new(name, body) ⇒ Source

Overloads:

  • .new(name:, body:) ⇒ Source

    Parameters:

    • name: (Symbol)
    • body: (String)

    Returns:

  • .new(name, body) ⇒ Source

    Parameters:

    • name (Symbol)
    • body (String)

    Returns:



9
10
# File 'sig/kobako/snippet/source.rbs', line 9

def self.new: (name: Symbol, body: String) -> Source
| (Symbol name, String body) -> Source