Sha256: ee71c947890bd664a2036d19fae8e4d3e01a4d17e198bc7d55bc3b621db1df55

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

require 'beryl/routing/matcher'

module Beryl
  module Routing
    class Router
      attr_reader :routes

      def initialize
        @routes = []
        draw
      end

      def match(path)
        @routes.each do |route|
          matched = Beryl::Routing::Matcher.match(route[0], path)
          return [route[1], matched] if matched
        end
        [:not_found]
      end

      private

      def draw
        eval(File.open(File.expand_path('./app/routes.rb')).read)
      end

      def route(path, route)
        @routes << [path, route]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
beryl-0.3.1 lib/beryl/routing/router.rb
beryl-0.3.0 lib/beryl/routing/router.rb