module Dry::Types::Coercions::Form
def self.to_ary(input)
-
(Array, Object)
-
Parameters:
-
input
(Array, String, Object
) --
def self.to_ary(input) empty_str?(input) ? [] : input end
def self.to_decimal(input)
-
(BigDecimal, nil, Object)
-
Parameters:
-
input
(#to_d, Object
) --
def self.to_decimal(input) result = to_float(input) if result.instance_of?(Float) input.to_d else result end end
def self.to_false(input)
- See: FALSE_VALUES -
See: TRUE_VALUES -
Returns:
-
(Boolean, Object)
-
Parameters:
-
input
(String, Object
) --
def self.to_false(input) BOOLEAN_MAP.fetch(input.to_s, input) end
def self.to_float(input)
-
(Float, nil, Object)
-
Parameters:
-
input
(#to_f, Object
) --
def self.to_float(input) if empty_str?(input) nil else Float(input) end rescue ArgumentError, TypeError input end
def self.to_hash(input)
-
(Hash, Object)
-
Parameters:
-
input
(Hash, String, Object
) --
def self.to_hash(input) empty_str?(input) ? {} : input end
def self.to_int(input)
-
(Integer, nil, Object)
-
Parameters:
-
input
(#to_int, #to_i, Object
) --
def self.to_int(input) if empty_str?(input) nil else Integer(input) end rescue ArgumentError, TypeError input end
def self.to_true(input)
- See: FALSE_VALUES -
See: TRUE_VALUES -
Returns:
-
(Boolean, Object)
-
Parameters:
-
input
(String, Object
) --
def self.to_true(input) BOOLEAN_MAP.fetch(input.to_s, input) end