Class: Decoding::Decoders::Lazy
- Inherits:
-
Decoding::Decoder
- Object
- Decoding::Decoder
- Decoding::Decoders::Lazy
- Defined in:
- lib/decoding/decoders/lazy.rb
Overview
A decoder that builds the decoder it delegates to on first use, rather than when it is created.
This is what makes recursive decoders possible: a decoder for a tree can refer to itself, since the reference is only resolved once there is a value to decode.
Instance Method Summary collapse
- #call(value) ⇒ Decoding::Result<a>
-
#initialize(&block) ⇒ Lazy
constructor
A new instance of Lazy.
Methods inherited from Decoding::Decoder
Constructor Details
#initialize(&block) ⇒ Lazy
Returns a new instance of Lazy.
17 18 19 20 |
# File 'lib/decoding/decoders/lazy.rb', line 17 def initialize(&block) @block = block super() end |
Instance Method Details
#call(value) ⇒ Decoding::Result<a>
24 |
# File 'lib/decoding/decoders/lazy.rb', line 24 def call(value) = decoder.call(value) |