lib/happy/controller/routing.rb in happy-0.1.0.pre15 vs lib/happy/controller/routing.rb in happy-0.1.0.pre16
- old
+ new
@@ -37,27 +37,14 @@
serve_or_404! instance_exec(&blk)
end
end
end
- def get(*args, &blk)
- args.last.is_a?(Hash) ? args.last.merge(:method => :get) : args.push(:method => :get)
- path(*args, &blk)
- end
-
- def post(*args, &blk)
- args.last.is_a?(Hash) ? args.last.merge(:method => :post) : args.push(:method => :post)
- path(*args, &blk)
- end
-
- def put(*args, &blk)
- args.last.is_a?(Hash) ? args.last.merge(:method => :put) : args.push(:method => :put)
- path(*args, &blk)
- end
-
- def delete(*args, &blk)
- args.last.is_a?(Hash) ? args.last.merge(:method => :delete) : args.push(:method => :delete)
- path(*args, &blk)
+ [:get, :post, :put, :delete].each do |method|
+ define_method(method) do |*args, &blk|
+ args.last.is_a?(Hash) ? args.last.merge(:method => method) : args.push(:method => method)
+ path(*args, &blk)
+ end
end
end
end
end