lib/ramaze/controller/resolve.rb in ramaze-2008.11 vs lib/ramaze/controller/resolve.rb in ramaze-2009.01
- old
+ new
@@ -14,11 +14,11 @@
# element of Ramaze::Controller::FILTER.
# If an element does not respond to call it will be sent to self
# instead, in either case with path as argument.
def resolve(path, routed = false)
- @routed = routed
+ Thread.current[:routed] = routed
FILTER.each do |filter|
answer = if filter.respond_to?(:call)
filter.call(path)
else
@@ -88,11 +88,11 @@
return action
end
end
end
- if !@routed and new_path = Route.resolve(path)
+ if !Thread.current[:routed] and new_path = Route.resolve(path)
Log.dev("Routing from `#{path}' to `#{new_path}'")
return resolve(new_path, true)
end
raise_no_action(first_controller, path) if first_controller
@@ -134,14 +134,19 @@
# Search the #template_paths for a fitting template for path.
# Only the first found possibility for the generated glob is returned.
def resolve_template(path)
path = path.to_s
- path_converted = path.split('__').inject{|s,v| s/v}
+ path_converted = path.split('__').inject{|s,v| File.join(s, v) }
possible_paths = [path, path_converted].compact
- paths = template_paths.map{|pa| possible_paths.map{|a| pa/a } }.flatten.uniq
+ paths = template_paths.map{|pa|
+ possible_paths.map{|a|
+ File.join(pa, a)
+ }
+ }.flatten.uniq
+
glob = "{#{paths.join(',')}}.{#{extension_order.join(',')}}"
Dir[glob].first
end
@@ -151,10 +156,10 @@
def template_paths
if paths = view_root
paths
else
- view_root(Global.view_root / Global.mapping.invert[self])
+ view_root(File.join(Global.view_root, Global.mapping.invert[self]))
end
end
# Based on methodname and arity, tries to find the right method on
# current controller.