lib/yaks/util.rb in yaks-0.7.5 vs lib/yaks/util.rb in yaks-0.7.6
- old
+ new
@@ -34,22 +34,31 @@
# @param [Object|Proc] maybe_proc
# A proc or a plain value
# @param [Object] context
# (optional) A context used to instance_eval the proc
def Resolve(maybe_proc, context = nil)
- if maybe_proc.is_a? Proc or maybe_proc.is_a? Method
+ if maybe_proc.respond_to?(:to_proc) && !maybe_proc.instance_of?(Symbol)
if context
if maybe_proc.arity > 0
context.instance_eval(&maybe_proc)
else
# In case it's a lambda with zero arity instance_eval fails
context.instance_exec(&maybe_proc)
end
else
- maybe_proc.()
+ maybe_proc.to_proc.()
end
else
maybe_proc
+ end
+ end
+
+ module Deprecated
+ def deprecated_alias(name, actual)
+ define_method name do |*args, &block|
+ $stderr.puts "WARNING: #{self.class}##{name} is deprecated, use `#{actual}'. at #{caller.first}"
+ send(actual, *args, &block)
+ end
end
end
end
end