Sha256: e5d138a6a859c0f55f7e44caa38b3cd37f14c0e5bdea3eb86383d31876df71d6
Contents?: true
Size: 754 Bytes
Versions: 25
Compression:
Stored size: 754 Bytes
Contents
module ApipieBindings class Route attr_reader :method, :description def initialize(path, method, description="") @path = path @method = method.downcase @description = description end def params_in_path @path.scan(/:([^\/]*)/).map { |m| m.first } end 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 def to_s "<Route #{@path}>" end def inspect to_s end end end
Version data entries
25 entries across 25 versions & 1 rubygems