lib/envied/coercer.rb in envied-0.8.2 vs lib/envied/coercer.rb in envied-0.9.0

- old
+ new

@@ -6,13 +6,18 @@ def to_array(str) str.split(/(?<!\\),/).map{|i| i.gsub(/\\,/,',') } end def to_hash(str) - require 'rack/utils' - ::Rack::Utils.parse_query(str) + require 'cgi' + ::CGI.parse(str).map { |key, values| [key, values[0]] }.to_h end + + def to_uri(str) + require 'uri' + ::URI.parse(str) + end end Coercible::Coercer::String.send(:include, CoercerExts) # Coerce strings to specific type. # @@ -36,10 +41,10 @@ coercer.method("to_#{type.downcase}") end def self.supported_types @supported_types ||= begin - [:hash, :array, :time, :date, :symbol, :boolean, :integer, :string].sort + [:hash, :array, :time, :date, :symbol, :boolean, :integer, :string, :uri, :float].sort end end # Whether or not Coercer can coerce strings to the provided type. #