Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
SingleForwardable#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.1.0-preview1/lib/forwardable.rb, line 270
def single_delegate(hash)
hash.each do |methods, accessor|
unless defined?(methods.each)
def_single_delegator(accessor, methods)
else
methods.each {|method| def_single_delegator(accessor, method)}
end
end
end
Alias of #single_delegate
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names. The value is the accessor to which the methods will be delegated.
See also
#single_delegate
#def_single_delegators
#def_single_delegator
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0