Sha256: ce531c83c4c46240e7d95bdcba71e0709f047808c6361f392dc44aab56b03018

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

require 'deas/sinatra_runner'

module Deas

  class Route

    attr_reader :method, :path, :handler_proxy, :handler_class

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

    def validate!
      @handler_class = @handler_proxy.handler_class
    end

    # TODO: unit test this??
    def run(sinatra_call)
      runner = Deas::SinatraRunner.new(self.handler_class, sinatra_call)
      sinatra_call.request.env.tap do |env|
        env['deas.params'] = runner.params
        env['deas.handler_class_name'] = self.handler_class.name
        env['deas.logging'].call "  Handler: #{env['deas.handler_class_name']}"
        env['deas.logging'].call "  Params:  #{env['deas.params'].inspect}"
      end
      runner.run
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deas-0.26.0 lib/deas/route.rb
deas-0.25.0 lib/deas/route.rb
deas-0.24.1 lib/deas/route.rb