lib/spiderfw/controller/dispatcher.rb in spiderfw-0.5.7 vs lib/spiderfw/controller/dispatcher.rb in spiderfw-0.5.9
- old
+ new
@@ -38,15 +38,15 @@
route = @dispatch_next[action]
if (!route.obj)
obj = dispatched_object(route)
obj.dispatch_previous = self if obj.respond_to?(:dispatch_previous=) && obj != self
route.obj = obj
+ if (route.options[:do])
+ obj.instance_exec(*(route.params || []), &route.options[:do])
+ end
end
- obj = route.obj
- if (route.options[:do])
- route.options[:do].call(obj, *(route.params || []))
- end
+ obj = route.obj
new_arguments = arguments
new_arguments += route.params unless route.options[:remove_params]
return [obj, route.action, new_arguments]
# return obj.send(method, route.action, *(new_arguments))
end
@@ -136,9 +136,10 @@
when Regexp
action_index = options[:action_match]
match = try.match(path)
if (match)
action = action_index ? match[action_index] : match.post_match
+ action = action[0..-2] if action.length > 0 && action[-1].chr == '/'
params = match[1..(match.length-1)]
matched = match[0]
end
when Proc
res = try.call(path, self)