Commit 86c2ca0a by cole bradley

set Big decimal precision for strings

parent 96152d09
......@@ -56,8 +56,10 @@ module RailsParam
return Array(param.split(options[:delimiter] || ",")) if type == Array
return Hash[param.split(options[:delimiter] || ",").map{|c| c.split(options[:separator] || ":")}] if type == Hash
return (/(false|f|no|n|0)$/i === param.to_s ? false : (/(true|t|yes|y|1)$/i === param.to_s ? true : nil)) if type == TrueClass || type == FalseClass || type == :boolean
return BigDecimal.new(param.delete('$,').strip) if type == BigDecimal && param.is_a?(String)
return BigDecimal.new(param, (options[:precision] || DEFAULT_PRECISION)) if type == BigDecimal
if type == BigDecimal
param = param.delete('$,').strip.to_f if param.is_a?(String)
return BigDecimal.new(param, (options[:precision] || DEFAULT_PRECISION)) if type == BigDecimal
end
return nil
rescue ArgumentError
raise InvalidParameterError, "'#{param}' is not a valid #{type}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment