lib/envied/coercer.rb in envied-0.9.0 vs lib/envied/coercer.rb in envied-0.9.1
- old
+ new
@@ -1,26 +1,9 @@
require 'coercible'
# Responsible for all string to type coercions.
class ENVied::Coercer
- module CoercerExts
- def to_array(str)
- str.split(/(?<!\\),/).map{|i| i.gsub(/\\,/,',') }
- end
-
- def to_hash(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.
#
# @param string [String] the string to be coerced
# @param type [#to_sym] the type to coerce to
#
@@ -67,10 +50,10 @@
def supported_types
self.class.supported_types
end
def coercer
- @coercer ||= Coercible::Coercer.new[String]
+ @coercer ||= Coercible::Coercer.new[ENViedString]
end
def coerced?(value)
!value.kind_of?(String)
end