module URITemplate::ClassMethods
Helper module which defines class methods for all uri template classes.
Public Instance Methods
convert(x)
click to toggle source
Same as {.try_convert} but raises an ArgumentError when the given argument could not be converted.
@raise ArgumentError if the argument is unconvertable @return {URITemplate}
# File lib/uri_template.rb, line 47 def convert(x) o = self.try_convert(x) if o.nil? raise ArgumentError, "Expected to receive something that can be converted into a URITemplate of type #{self.inspect}, but got #{x.inspect}" end return o end
included(base)
click to toggle source
# File lib/uri_template.rb, line 55 def included(base) base.extend(ClassMethods) end
try_convert(x)
click to toggle source
Tries to convert the given argument into an {URITemplate}. Returns nil if this fails.
@return [nil|{URITemplate}]
# File lib/uri_template.rb, line 33 def try_convert(x) if x.kind_of? self return x elsif x.kind_of? String return self.new(x) else return nil end end