Class: Plumb::Codec::Forms
- Inherits:
-
Plumb::Codec
- Object
- Plumb::Codec
- Plumb::Codec::Forms
- Defined in:
- lib/plumb/codec.rb
Overview
A base codec for string-based formats — HTML forms, query strings, CSV cells — where EVERY value arrives as a string. Unlike Codec::JSON there are almost no native scalars: strings pass through, untyped containers recurse structurally (Rack-style nested params), and everything else maps through an encoder whose input type is a strictly-patterned string.
Config = Types::Hash[port: Types::Integer, active: Types::Boolean, on: Types::Date]
decoder, encoder = Plumb::Codec::Forms.for(Config)
decoder.parse({ port: '80', active: '1', on: '2024-01-30' })
# => { port: 80, active: true, on: Date(2024-01-30) }
Defined Under Namespace
Classes: FalseEncoder, FloatEncoder, IntegerEncoder, NilEncoder, NumericEncoder, TrueEncoder
Constant Summary collapse
- INTEGER_EXPR =
/\A-?\d+\z/
Constants inherited from Plumb::Codec
FLOAT_EXPR, FileURIEncoder, HTTPURIEncoder, NoEntryError, TIME_EXPR, URI_EXPR
Method Summary
Methods inherited from Plumb::Codec
>>, at_path, call, #decode, #encode, encoder, encoder_for, for, #freeze, inherited, #initialize, inspect, #inspect, #key?, noop, noop?, noop_value?, #register, to_composable, to_plumb_type, |
Constructor Details
This class inherits a constructor from Plumb::Codec