class Gravaty::Parsers::Default
This class is an implementation of the Parsable duck type that checks the default option. The only needed parameter is a valid default option.
- Author
- Copyright
-
Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
- License
-
GNU General Public License version 3
Public Instance Methods
parse(value = nil)
click to toggle source
The parsable duck type interface to every parser usage.
# File lib/gravaty/parsers/default.rb 38 def parse(value = nil) 39 unless value.nil? or value.empty? 40 unless DEFAULT_OPTIONS.include? value 41 valid = %w(http https).index { |scheme| valid?(value, scheme) } 42 43 raise ArgumentError, I18n.t('error.uri', value: value) if valid.nil? 44 end 45 46 return 'd=' + CGI::escape(value).to_s 47 end 48 '' 49 end