Sha256: b410ff4930cdb1c3625b17d91cb44a7bfbfa53af6cf81c590be5f9c202547064
Contents?: true
Size: 866 Bytes
Versions: 2
Compression:
Stored size: 866 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::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
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
joshbuddy-usher-0.4.8 | lib/usher/interface/rack_interface.rb |
usher-0.4.8 | lib/usher/interface/rack_interface.rb |