Module: CMDx::Coercions::Integer
Overview
Coerces to Integer via ‘Kernel#Integer` (strict; rejects floats-as-strings).
Instance Method Summary collapse
Instance Method Details
#call(value, options = EMPTY_HASH) ⇒ Integer, Coercions::Failure
14 15 16 17 18 19 |
# File 'lib/cmdx/coercions/integer.rb', line 14 def call(value, = EMPTY_HASH) Integer(value) rescue ArgumentError, FloatDomainError, RangeError, TypeError type = I18nProxy.t("cmdx.types.integer") Failure.new(I18nProxy.t("cmdx.coercions.into_an", type:)) end |