Sha256: 90b64cce399f63bd7b9c7e4915c8efe65599b69f8b903efa9ac85fc7d7fd3562
Contents?: true
Size: 679 Bytes
Versions: 10
Compression:
Stored size: 679 Bytes
Contents
module Compel module Coercion class Result attr_reader :coerced, :value, :klass, :error def initialize(coerced, value, klass, coercion_error = nil) @coerced = coerced @value = value @klass = klass @error = coercion_error.nil? ? standard_error : coercion_error end def valid? @error.nil? end private def standard_error if !klass.nil? && coerced.nil? "'#{value}' is not a valid #{klass_final_type}" end end def klass_final_type "#{klass}".split('::')[-1] end end end end
Version data entries
10 entries across 10 versions & 1 rubygems