Sha256: 90541bd7edb2b1753d3b1013fc0b85ae1cb2b007ab137625071c1d1accdc31d4

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Routing
    class Router
      ArgumentCountError = Class.new(StandardError) # TODO: Unused, remove

      extend Forwardable

      attr_reader :root,
                  :blocks

      def initialize
        @blocks = []
      end

      def draw(&block)
        @blocks.push(block)
      end

      def invoke(url, arguments)
        @root = Wayfarer::Routing::RootRoute.new
        @blocks.each { |block| Docile.dsl_eval(@root, *arguments, &block) }
        root.invoke(url)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wayfarer-0.4.6 lib/wayfarer/routing/router.rb
wayfarer-0.4.5 lib/wayfarer/routing/router.rb
wayfarer-0.4.4 lib/wayfarer/routing/router.rb