Sha256: c13a4048d5c14b433277a55b99d6a4897d45a2254efb1991bbe2ea9117d4a3b4

Contents?: true

Size: 638 Bytes

Versions: 5

Compression:

Stored size: 638 Bytes

Contents

require 'deas/exceptions'

module Deas

  class Route

    attr_reader :method, :path, :handler_proxies

    def initialize(method, path, handler_proxies)
      @method, @path, @handler_proxies = method, path, handler_proxies
    end

    def validate!
      @handler_proxies.each do |request_type_name, proxy|
        proxy.validate!
      end
    end

    def run(sinatra_call)
      type = sinatra_call.settings.router.request_type_name(sinatra_call.request)
      proxy = begin
        @handler_proxies[type]
      rescue HandlerProxyNotFound
        sinatra_call.halt(404)
      end
      proxy.run(sinatra_call)
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
deas-0.36.0 lib/deas/route.rb
deas-0.35.0 lib/deas/route.rb
deas-0.34.0 lib/deas/route.rb
deas-0.33.0 lib/deas/route.rb
deas-0.32.0 lib/deas/route.rb