Module: Castkit::AttributeExtensions::Casting

Includes:
ErrorHandling
Included in:
Castkit::Attribute
Defined in:
lib/castkit/attribute_extensions/casting.rb

Overview

Provides typecasting logic for attributes based on their declared type.

Supports primitive types, arrays, nested Castkit::DataObject types, and union types.

Constant Summary collapse

PRIMITIVE_CASTERS =
{
  integer: lambda(&:to_i),
  float: lambda(&:to_f),
  string: lambda(&:to_s),
  hash: ->(v) { v },
  array: ->(v) { Array(v) }
}.freeze

Constants included from ErrorHandling

ErrorHandling::ERROR_OPTIONS