Module: Plumb::Types

Extended by:
TypeRegistry
Defined in:
lib/plumb/types.rb

Defined Under Namespace

Modules: Forms, Lax, URI, UUID Classes: Data

Constant Summary collapse

Any =
AnyClass.new
Undefined =
Any.value(Plumb::Undefined)
String =
Any[::String]
Symbol =
Any[::Symbol]
Numeric =
Any[::Numeric]
Integer =
Any[::Integer]
Decimal =
Any[BigDecimal]
Static =
StaticClass.new
Value =
ValueClass.new
Nil =
Any[::NilClass]
True =
Any[::TrueClass]
False =
Any[::FalseClass]
Boolean =
(True | False).as_node(:boolean)
Array =
ArrayClass.new
Stream =
StreamClass.new
Tuple =
TupleClass.new
Hash =
HashClass.new
Not =
Plumb::Not.new
Interface =
InterfaceClass.new
Email =
String[URI::MailTo::EMAIL_REGEXP].as_node(:email)
Date =
Any[::Date]
Time =
Any[::Time]
SymbolizedHash =

A type that recursively converts string keys to symbols in nested hashes. This is commonly used for normalizing payload data in commands and events.

Examples:

Simple hash symbolization

SymbolizedHash.parse({ 'name' => 'John' })  # => { name: 'John' }

Nested hash symbolization

SymbolizedHash.parse({ 'user' => { 'name' => 'John' } })  # => { user: { name: 'John' } }

Mixed types preserved

SymbolizedHash.parse({ 'count' => 1, 'active' => true })  # => { count: 1, active: true }
Hash[
  # String keys are converted to symbols, existing symbols are preserved
  (Symbol | String.transform(::Symbol, &:to_sym)),
  # Hash values are recursively symbolized, other types pass through unchanged
  Any.defer { SymbolizedHash } | Any
]

Method Summary

Methods included from TypeRegistry

const_added, included