aboutsummaryrefslogtreecommitdiffstats
path: root/lib/forwardable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/forwardable.rb')
-rw-r--r--lib/forwardable.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 0c04fb3a27..cc5ac15001 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -131,7 +131,7 @@ module Forwardable
#
def instance_delegate(hash)
hash.each{ |methods, accessor|
- methods = [methods] unless methods.respond_to?(:each)
+ methods = [methods] unless defined?(methods.each)
methods.each{ |method|
def_instance_delegator(accessor, method)
}
@@ -204,7 +204,7 @@ module Forwardable
mesg = "#{Module === obj ? obj : obj.class}\##{ali} at #{loc.path}:#{loc.lineno} forwarding to private method "
method_call = "#{<<-"begin;"}\n#{<<-"end;".chomp}"
begin;
- unless ::Kernel.instance_method(:respond_to?).bind(_).call(:"#{method}")
+ unless defined? _.#{method}
::Kernel.warn "\#{caller_locations(1)[0]}: "#{mesg.dump}"\#{_.class}"'##{method}'
_#{method_call}
else
@@ -262,7 +262,7 @@ module SingleForwardable
#
def single_delegate(hash)
hash.each{ |methods, accessor|
- methods = [methods] unless methods.respond_to?(:each)
+ methods = [methods] unless defined?(methods.each)
methods.each{ |method|
def_single_delegator(accessor, method)
}