Sha256: eebcf3d088e8ff53d7ba56096bd4eb880d5bf1b596288fb7c932dde797e67460

Contents?: true

Size: 647 Bytes

Versions: 3

Compression:

Stored size: 647 Bytes

Contents

$:.unshift File.dirname(__FILE__)

require 'rack_interface/route'

class Usher
  module Interface
    class RackInterface
      
      Request = Struct.new(:path, :method)
      
      def initialize
        @routes = Usher.new
      end
      
      def add(path, options = {})
        @routes.add_route(path, options)
      end

      def reset!
        @routes.reset!
      end

      def call(env)
        response = @routes.recognize(Request.new(env['REQUEST_URI'], env['REQUEST_METHOD']))
        env['usher.params'] = response.params.inject({}){|h,(k,v)| h[k]=v; h }
        response.path.route.params.call(env)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joshbuddy-usher-0.2.1 lib/usher/interface/rack_interface.rb
joshbuddy-usher-0.2.2 lib/usher/interface/rack_interface.rb
joshbuddy-usher-0.3.0 lib/usher/interface/rack_interface.rb