summaryrefslogtreecommitdiff
path: root/bocelli/module
diff options
context:
space:
mode:
Diffstat (limited to 'bocelli/module')
-rw-r--r--bocelli/module/base.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/bocelli/module/base.rb b/bocelli/module/base.rb
index 1306830..45b09d7 100644
--- a/bocelli/module/base.rb
+++ b/bocelli/module/base.rb
@@ -13,6 +13,19 @@ module Bocelli
@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) }
+ end
+
class << self
def extended(mod)
super