Sha256: aa0adf46633cc4a95d6072c9844a8bbc2c574ac75b36e552d0ed860415eb9565

Contents?: true

Size: 511 Bytes

Versions: 2

Compression:

Stored size: 511 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Routing
    class Router
      ArgumentCountError = Class.new(StandardError)

      extend Forwardable

      attr_reader :root

      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

2 entries across 2 versions & 1 rubygems

Version Path
wayfarer-0.4.3 lib/wayfarer/routing/router.rb
wayfarer-0.4.2 lib/wayfarer/routing/router.rb