lib/abstractivator/proc_ext.rb in abstractivator-0.0.21 vs lib/abstractivator/proc_ext.rb in abstractivator-0.0.22
- old
+ new
@@ -28,10 +28,13 @@
self.call(*args.reverse, &block)
end
end
def self.loose_call(x, args, &block)
- x.respond_to?(:call) ? x.call(*args.take(x.arity).pad_right(x.arity), &block) : x
+ x = x.to_proc if x.respond_to?(:to_proc)
+ x.respond_to?(:call) or return x
+ args = args.take(x.arity).pad_right(x.arity) if x.arity >= 0
+ x.call(*args, &block)
end
end
class Method
include MethodAndProcExtensions