Class: ContainerConfig::Coercer::Integer

Inherits:
Base
  • Object
show all
Defined in:
lib/container_config/coercer/integer.rb

Overview

Integer type coercer

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Integer

Coerces the given value into an integer

Parameters:

  • value (Object)

    given value

Returns:



26
27
28
29
30
# File 'lib/container_config/coercer/integer.rb', line 26

def coerce(value)
  return 0 unless value.respond_to?(:to_i)

  value.to_i
end

#nameObject

See Also:



10
11
12
# File 'lib/container_config/coercer/integer.rb', line 10

def name
  "Integer"
end

#typeObject

See Also:



15
16
17
# File 'lib/container_config/coercer/integer.rb', line 15

def type
  :integer
end