Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move cloning dests into route class

  • Loading branch information...
commit 23290f9091df2e62d8c6f1a977700e9f250308fb 1 parent 6c7285f
@joshbuddy authored
Showing with 6 additions and 11 deletions.
  1. +0 −5 lib/http_router.rb
  2. +6 −6 lib/http_router/route.rb
View
5 lib/http_router.rb
@@ -178,11 +178,6 @@ def clone(klass = self.class)
@routes.each do |route|
new_route = route.clone(cloned_router)
cloned_router.add_route(new_route)
- begin
- new_route.to route.dest.clone
- rescue
- new_route.to route.dest
- end
end
cloned_router
end
View
12 lib/http_router/route.rb
@@ -1,7 +1,6 @@
class HttpRouter
class Route
- attr_reader :default_values, :router, :conditions, :original_path, :match_partially, :dest, :regex, :name, :matches_with, :app
- alias_method :dest, :app
+ attr_reader :default_values, :router, :conditions, :original_path, :match_partially, :dest, :regex, :name, :matches_with, :dest
alias_method :match_partially?, :match_partially
alias_method :regex?, :regex
@@ -40,9 +39,9 @@ def static(root)
}
end
- def to(app = nil, &app2)
- @app = app || app2 || raise("you didn't specify a destination")
- if @app.respond_to?(:url_mount=)
+ def to(dest = nil, &dest_block)
+ @dest = dest || dest_block || raise("you didn't specify a destination")
+ if @dest.respond_to?(:url_mount=)
urlmount = UrlMount.new(original_path, @default_values || {})
urlmount.url_mount = router.url_mount if router.url_mount
dest.url_mount = urlmount
@@ -60,7 +59,8 @@ def url(*args)
end
def clone(new_router)
- Route.new(new_router, @original_path.dup, as_options).to(@app)
+ r = Route.new(new_router, @original_path.dup, as_options).to(dest)
+ r.to(begin; dest.clone; rescue; dest; end)
end
def url_with_params(*a)
Please sign in to comment.
Something went wrong with that request. Please try again.