Permalink
Browse files

simpler

  • Loading branch information...
1 parent adf5bb3 commit 3f810ef8b00f1f94bb2bfb0b690a60c43897ccfb @joshbuddy committed Sep 7, 2011
Showing with 6 additions and 6 deletions.
  1. +2 −0 lib/http_router.rb
  2. +0 −2 lib/http_router/node/root.rb
  3. +2 −2 lib/http_router/regex_route.rb
  4. +2 −2 lib/http_router/route.rb
View
@@ -210,13 +210,15 @@ def inspect
def compile
return if @compiled
@routes.each {|r| r.send(:compile)}
+ @root.compile
instance_eval "undef :url; alias :url :raw_url; undef :call; alias :call :raw_call", __FILE__, __LINE__
@compiled = true
end
def uncompile
return unless @compiled
instance_eval "undef :url; alias :url :compiling_url; undef :call; alias :call :compiling_call", __FILE__, __LINE__
+ @root.uncompile
@compiled = false
end
@@ -36,9 +36,7 @@ def inspect_label
"Root (#{@matchers.size} matchers)"
end
- private
def compile
- router.send(:compile)
root.extend(root.methods_module)
instance_eval "def [](request)\n#{to_code}\nnil\nend", __FILE__, __LINE__
@compiled = true
@@ -1,7 +1,7 @@
class HttpRouter
class RegexRoute < Route
- def initialize(router, path, opts = nil)
- @router, @original_path, @opts = router, path, opts
+ def initialize(router, original_path, opts = nil, &blk)
+ @router, @original_path, @opts, @dest = router, original_path, opts, blk
@param_names = @original_path.respond_to?(:names) ? @original_path.names.map(&:to_sym) : []
@path_validation_regex = original_path
Util.add_path_generation(self, self, opts.delete(:path_for_generation), @original_path) if opts.key?(:path_for_generation)
View
@@ -4,8 +4,8 @@ class Route
alias_method :match_partially?, :match_partially
alias_method :regex?, :regex
- def initialize(router, original_path, opts = nil)
- @router, @original_path, @opts = router, original_path, opts
+ def initialize(router, original_path, opts = nil, &blk)
+ @router, @original_path, @opts, @dest = router, original_path, opts, blk
process_path
process_opts if opts
process_match_with

0 comments on commit 3f810ef

Please sign in to comment.