Sha256: 0a06310d68294abff542b6804e476bf780b1e75339c9538c6675d05a4717ace2

Contents?: true

Size: 579 Bytes

Versions: 4

Compression:

Stored size: 579 Bytes

Contents

module Adhearsion
  class Router
    extend ActiveSupport::Autoload

    autoload :Route

    attr_reader :routes

    def initialize(&block)
      @routes = []
      instance_exec &block
    end

    def route(*args, &block)
      Route.new(*args, &block).tap do |route|
        @routes << route
      end
    end

    def match(call)
      @routes.find { |route| route.match? call }
    end

    def handle(call)
      return unless route = match(call)
      logger.debug "Call #{call.id} passing through router matched route #{route}"
      route.dispatcher
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adhearsion-2.0.0.beta1 lib/adhearsion/router.rb
adhearsion-2.0.0.alpha3 lib/adhearsion/router.rb
adhearsion-2.0.0.alpha2 lib/adhearsion/router.rb
adhearsion-2.0.0.alpha1 lib/adhearsion/router.rb