Class: Kobako::Codec::Factory
- Inherits:
-
Object
- Object
- Kobako::Codec::Factory
- Extended by:
- Forwardable, SingleForwardable
- Includes:
- Singleton
- Defined in:
- lib/kobako/codec/factory.rb
Overview
Cached MessagePack::Factory that owns the kobako wire ext-type registration (SPEC.md → Wire Codec → Ext Types).
The factory is the single place in the host gem that touches the msgpack API — both Encoder and Decoder delegate through it, so the three kobako ext codes (0x00 Symbol, 0x01 Capability Handle, 0x02 Exception envelope) are configured exactly once at first use.
Lifecycle is owned by Singleton from the Ruby standard library: Factory.instance is lazy, thread-safe, and process-wide. Class-level Factory.dump / Factory.load shortcuts are exposed via SingleForwardable so callers do not have to spell the .instance hop at every call site; the instance-level #dump / #load are in turn delegated to the wrapped MessagePack::Factory via Forwardable.
Instance Method Summary collapse
-
#initialize ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize ⇒ Factory
Returns a new instance of Factory.
59 60 61 62 63 64 |
# File 'lib/kobako/codec/factory.rb', line 59 def initialize @factory = MessagePack::Factory.new register_symbol register_handle register_fault end |