Sha256: d6df2e7aa6e9c7395a839f765ab290bc5ceef68e1a070e3d7dbd3c106bec60e4
Contents?: true
Size: 872 Bytes
Versions: 3
Compression:
Stored size: 872 Bytes
Contents
require 'rack' class Usher module Interface class RackInterface attr_accessor :routes def initialize(&blk) @routes = Usher.new(:request_methods => [:method, :host, :port, :scheme]) @generator = Usher::Util::Generators::URL.new(@routes) instance_eval(&blk) if blk end def add(path, options = nil) @routes.add_route(path, options) end def reset! @routes.reset! end def call(env) response = @routes.recognize(Rack::Request.new(env)) params = {} response.params.each{ |hk| params[hk.first] = hk.last} env['usher.params'] = params response.path.route.destination.call(env) end def generate(route, params = nil, options = nil) @generator.generate(route, params, options) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
joshbuddy-usher-0.4.10 | lib/usher/interface/rack_interface.rb |
joshbuddy-usher-0.4.11 | lib/usher/interface/rack_interface.rb |
joshbuddy-usher-0.5.1 | lib/usher/interface/rack_interface.rb |