Sha256: 070e56d9f4d209a43f8568e3251f01742ae1f3823089abf8ba8a3e09f7403454
Contents?: true
Size: 969 Bytes
Versions: 2
Compression:
Stored size: 969 Bytes
Contents
require 'compel/coercion/types/type' require 'compel/coercion/types/integer' require 'compel/coercion/types/float' require 'compel/coercion/types/string' require 'compel/coercion/types/date' require 'compel/coercion/types/time' require 'compel/coercion/types/datetime' require 'compel/coercion/types/hash' require 'compel/coercion/types/json' require 'compel/coercion/types/boolean' require 'compel/coercion/types/regexp' require 'compel/coercion/types/array' require 'compel/coercion/types/any' require 'compel/coercion/result' require 'compel/coercion/nil_result' module Compel module Coercion def coerce!(value, type, options = {}) result = coerce(value, type, options) unless result.valid? raise Compel::TypeError, result.error end result.coerced end def coerce(value, type, options = {}) return Coercion::NilResult.new if value.nil? type.coerce(value, options) end extend self end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
compel-0.3.6 | lib/compel/coercion/coercion.rb |
compel-0.3.4 | lib/compel/coercion/coercion.rb |