lib/saneitized/converter.rb in saneitized-1.2.0 vs lib/saneitized/converter.rb in saneitized-1.3.0
- old
+ new
@@ -1,26 +1,25 @@
require 'json'
require 'chronic'
module Saneitized
- def self.convert(unknown)
+
+ def self.convert(unknown, options = {})
+ options[:blacklist] ||= nil
return Saneitized::Hash.new(unknown) if unknown.is_a? ::Hash
return Saneitized::Array.new(unknown) if unknown.is_a? ::Array
return unknown unless unknown.is_a? String #Only attempt to convert string
+ return unknown if Array(options[:blacklist]).include?(unknown)
%w(true false nil integer float json time).each do |type|
value = Converter.send(type + '?', unknown)
next if value == :nope
return (type == 'json') ? convert(value) : value
end
- #if value = Converter.integer?(unknown) then return value end
- #if value = Converter.float?(unknown) then return value end
- #if (value = Converter.json?(unknown)) != :nope then return convert(value) end
- #if value = Converter.time?(unknown) then return value end
-
unknown
end
+
module Converter
extend self
def true?(unknown)