lib/happy/controller/routing.rb in happy-0.1.0.pre22 vs lib/happy/controller/routing.rb in happy-0.1.0.pre23

- old
+ new

@@ -5,11 +5,11 @@ # Since we want to be compatible with Ruby 1.8.7, we unfortunately can't use named captures like this: # Regexp.compile('^'+path.gsub(/\)/, ')?').gsub(/\//, '\/').gsub(/\./, '\.').gsub(/:(\w+)/, '(?<\\1>.+)')+'$') Regexp.compile('^'+path.gsub(/\)/, ')?').gsub(/\//, '\/').gsub(/\./, '\.').gsub(/:(\w+)/, '(.+)')+'$') end - def path?(*args, &blk) + def on(*args, &blk) options = (args.pop if args.last.is_a?(Hash)) || {} args = [nil] if args.empty? args.each do |name| # If a path name has been given, match it against the next request path part. @@ -38,12 +38,12 @@ end end end [:get, :post, :put, :delete].each do |method| - define_method("#{method}?") do |*args, &blk| + define_method("on_%s" % method) do |*args, &blk| args.last.is_a?(Hash) ? args.last.merge(:method => method) : args.push(:method => method) - path?(*args, &blk) + on(*args, &blk) end end end end end