lib/handles_timeout.rb in keikokuc-0.0.3 vs lib/handles_timeout.rb in keikokuc-0.1

- old
+ new

@@ -6,12 +6,16 @@ RequestTimeout = Class.new module ClassMethods def handle_timeout(method_name) alias_method "#{method_name}_without_timeout", method_name - define_method method_name do |args| + define_method method_name do |*args| begin - Timeout::timeout(5) { send("#{method_name}_without_timeout", args) } + if args.empty? + Timeout::timeout(5) { send("#{method_name}_without_timeout") } + else + Timeout::timeout(5) { send("#{method_name}_without_timeout", *args) } + end rescue Timeout::Error [nil, RequestTimeout] end end end