From 36b3ad8cd10a2635723e847e2c801a1cd8fb5415 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 18 Aug 2014 23:24:32 -0700 Subject: Less code duplication. --- bocelli/module/base.rb | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'bocelli/module') diff --git a/bocelli/module/base.rb b/bocelli/module/base.rb index 45b09d7..f338c34 100644 --- a/bocelli/module/base.rb +++ b/bocelli/module/base.rb @@ -1,29 +1,12 @@ +require_relative '../core/router' + module Bocelli module Module module Base - attr_reader :routes + include Bocelli::Core::Router def setup - @routes = {} - end - - def on(route, &block) - raise 'no block given' if block.nil? - - @routes[route] = block - end - - def match?(str, route) - case route - when Regexp - str =~ route - when String - str == route - end - end - - def match(str) - @routes.detect { |k, _| match?(str, k) } + setup_router end class << self -- cgit v1.2.3-70-g09d2