lib/forwardable/extended.rb
def def_delegator(accessor, method, alias_ = method, **kwd)
      kwd, alias_ = alias_, method if alias_.is_a?(Hash) && !kwd.any?

      if alias_.is_a?(Hash) || !kwd.any?
        Forwardable.instance_method(:def_delegator).bind(self) \
          .call(accessor, method, alias_)

      elsif !kwd[:type]
        def_modern_delegator(
          accessor, method, alias_, **kwd
        )

      else
        raise ArgumentError, "Alias not supported." if alias_ != method
        send("def_#{kwd[:type]}_delegator", accessor, method, **kwd.tap do |obj|
          obj.delete(:type)
        end)
      end
    end
def def_delegator(accessor, method, alias_ = method, **kwd)
      kwd, alias_ = alias_, method if alias_.is_a?(Hash) && !kwd.any?

      if alias_.is_a?(Hash) || !kwd.any?
        Forwardable.instance_method(:def_delegator).bind(self) \
          .call(accessor, method, alias_)

      elsif !kwd[:type]
        def_modern_delegator(
          accessor, method, alias_, **kwd
        )

      else
        raise ArgumentError, "Alias not supported." if alias_ != method
        send("def_#{kwd[:type]}_delegator", accessor, method, **kwd.tap do |obj|
          obj.delete(:type)
        end)
      end
    end
def def_delegator ( accessor , method , alias_ = method , ** kwd ) kwd , alias_ = alias_ , method if alias_ . is_a? ( Hash ) && ! kwd . any? if alias_ . is_a? ( Hash ) || ! kwd . any? Forwardable . instance_method ( :def_delegator ) . bind ( self ) . call ( accessor , method , alias_ ) elsif ! kwd [ :type ] def_modern_delegator ( accessor , method , alias_ , ** kwd ) else raise ArgumentError , "Alias not supported." if alias_ != method send ( "def_#{kwd[:type]}_delegator" , accessor , method , ** kwd . tap do | obj | obj . delete ( :type ) end ) end end
------------------------------------------------------------------------
 Wraps around traditional delegation and modern delegation.
 ------------------------------------------------------------------------
------------------------------------------------------------------------ Wraps around traditional delegation and modern delegation . ------------------------------------------------------------------------