Class: Parameters::Types::URI
- Defined in:
- lib/parameters/types/uri.rb
Class Method Summary collapse
-
.===(value) ⇒ Boolean
Determines if the value is already a URI.
-
.coerce(value) ⇒ URI::Generic
Coerces a value into a URI.
Methods inherited from Object
Methods inherited from Type
#<, #<=, #==, #===, #coerce, #to_ruby, to_ruby
Class Method Details
.===(value) ⇒ Boolean
Determines if the value is already a URI.
18 19 20 |
# File 'lib/parameters/types/uri.rb', line 18 def self.===(value) value.kind_of?(::URI::Generic) end |
.coerce(value) ⇒ URI::Generic
Coerces a value into a URI.
31 32 33 34 35 36 37 |
# File 'lib/parameters/types/uri.rb', line 31 def self.coerce(value) if value.respond_to?(:to_uri) value.to_uri else ::URI.parse(value.to_s) end end |