Module: ResultClassComponents::TypeCasting
- Defined in:
- lib/kweerie/result_class_components/type_casting.rb
Instance Method Summary collapse
Instance Method Details
#type_cast_value(value, type_definition) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kweerie/result_class_components/type_casting.rb', line 5 def type_cast_value(value, type_definition) return value if type_definition.nil? case type_definition when Symbol public_send(type_definition, value) when Proc type_definition.call(value) when Class type_definition.new.cast(value) else raise ArgumentError, "Unsupported type definition: #{type_definition}" end end |