instance method
Forwardable#instance_delegate
(::Hash[::Symbol | ::Array[::Symbol], ::Symbol] hash) -> void
delegate method => accessor
delegate [method, method, ...] => accessor
lib/forwardable.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/forwardable.rb, line 135
def instance_delegate(hash)
hash.each do |methods, accessor|
unless defined?(methods.each)
def_instance_delegator(accessor, methods)
else
methods.each {|method| def_instance_delegator(accessor, method)}
end
end
end
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names, instance variable names, or constant names (see def_delegator). The value is the accessor to which the methods will be delegated.