lib/forwardable/extended.rb
def def_hash_delegator(hash, method, key: method, **kwd)
      prefix, suffix, wrap = prepare_delegate(**kwd)

      if suffix
        method = method.to_s.gsub(
          /\?$/, ""
        )
      end

      class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9
        def #{method}#{suffix}(*args)
          #{wrap}(
            #{prefix}#{hash}[#{key.inspect}]
          )

        rescue Exception
          if !Forwardable.debug && $@ && $@.respond_to?(:delete_if)
            $@.delete_if do |source|
              source =~ %r"#{Regexp.escape(__FILE__)}"o
            end
          end

          raise
        end
      STR
    end
def def_hash_delegator(hash, method, key: method, **kwd)
      prefix, suffix, wrap = prepare_delegate(**kwd)

      if suffix
        method = method.to_s.gsub(
          /\?$/, ""
        )
      end

      class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9
        def #{method}#{suffix}(*args)
          #{wrap}(
            #{prefix}#{hash}[#{key.inspect}]
          )

        rescue Exception
          if !Forwardable.debug && $@ && $@.respond_to?(:delete_if)
            $@.delete_if do |source|
              source =~ %r"#{Regexp.escape(__FILE__)}"o
            end
          end

          raise
        end
      STR
    end
def def_hash_delegator ( hash , method , key : method , ** kwd ) prefix , suffix , wrap = prepare_delegate ( ** kwd ) if suffix method = method . to_s . gsub ( / \? / , "" ) end class_eval delegate_debug ( <<-STR ) , __FILE__ , __LINE__ - 9 #{ method } #{ suffix } #{ wrap } #{ prefix } #{ hash } #{ key . inspect } #{ Regexp . escape ( __FILE__ ) } STR end
------------------------------------------------------------------------
 Delegate a method to a hash and key.
 ------------------------------------------------------------------------
------------------------------------------------------------------------ Delegate a method to a hash and key . ------------------------------------------------------------------------