class ApipieBindings::Route
Attributes
description[R]
method[R]
Public Class Methods
new(path, method, description="")
click to toggle source
# File lib/apipie_bindings/route.rb, line 7 def initialize(path, method, description="") @path = path @method = method.downcase @description = description end
Public Instance Methods
inspect()
click to toggle source
# File lib/apipie_bindings/route.rb, line 31 def inspect to_s end
params_in_path()
click to toggle source
# File lib/apipie_bindings/route.rb, line 13 def params_in_path @path.scan(/:([^\/]*)/).map { |m| m.first } end
path(params=nil)
click to toggle source
# File lib/apipie_bindings/route.rb, line 17 def path(params=nil) return @path if params.nil? path = params_in_path.inject(@path) do |p, param_name| param_value = (params[param_name.to_sym] or params[param_name.to_s]) or raise ArgumentError, "missing param '#{param_name}' in parameters" p.sub(":#{param_name}", URI.escape(param_value.to_s)) end end
to_s()
click to toggle source
# File lib/apipie_bindings/route.rb, line 27 def to_s "<Route #{@path}>" end