Ravn::
Delegation module
A collection of various delegation code-generators that can be used to define delegation through other methods, to instance variables, etc.
Public Instance Methods
Define the given delegated_methods
as delegators to the like-named class method.
Define the given delegated_methods
as delegators to the like-named method of the specified ivar
. This is pretty much identical with how ‘Forwardable’ from the stdlib does delegation, but it’s reimplemented here for consistency.
class MyClass extend Strelka::Delegation
# Delegate the #each method to the @collection ivar def_ivar_delegators :@collection, :each
end
Define the given delegated_methods
as delegators to the like-named method of the return value of the delegate_method
.
class MyClass extend Strelka::Delegation
# Delegate the #bound?, #err, and #result2error methods to the connection # object returned by the #connection method. This allows the connection # to still be loaded on demand/overridden/etc. def_method_delegators :connection, :bound?, :err, :result2error def connection @connection ||= self.connect end
end