lib/forwardablex.rb
def forward_as_key(receiver, key, name=key)
    context = self.kind_of?(Module) ? self : self.singleton_class
    context.instance_eval do
      case receiver
      when :class
        forward_class_receiver(:[], name, key)
      when :identity
        forward_identity_receiver(name)
      when Symbol, String
        forward_named_receiver(receiver, :[], name, key)
      when Proc
        forward_proc_receiver(receiver, :[], name, key)
      else
        forward_object_receiver(receiver, :[], name, key)
      end
    end
  end
# Define a method that forwards the key to the receiver. You can specify
# receiver as instance variable name, Proc object, and plain object.
#
# @param receiver [Symbol, String, Proc, or Object]
#   message receiver that have method #[]
# @param key [Symbol]
#   key that we forward to the receiver
# @param name [Symbol]
#   method name that we forward from
# @return [void]
Define a method that forwards the key to the receiver. You can specify
receiver as instance variable name, Proc object, and plain object.
Define a method that forwards the key to the receiver . You can specify receiver as instance variable name Proc object and plain object .
def forward_as_key(receiver, key, name=key)
    context = self.kind_of?(Module) ? self : self.singleton_class
    context.instance_eval do
      case receiver
      when :class
        forward_class_receiver(:[], name, key)
      when :identity
        forward_identity_receiver(name)
      when Symbol, String
        forward_named_receiver(receiver, :[], name, key)
      when Proc
        forward_proc_receiver(receiver, :[], name, key)
      else
        forward_object_receiver(receiver, :[], name, key)
      end
    end
  end
def forward_as_key ( receiver , key , name = key ) context = self . kind_of? ( Module ) ? self : self . singleton_class context . instance_eval do case receiver when :class forward_class_receiver ( :[] , name , key ) when :identity forward_identity_receiver ( name ) when Symbol , String forward_named_receiver ( receiver , :[] , name , key ) when Proc forward_proc_receiver ( receiver , :[] , name , key ) else forward_object_receiver ( receiver , :[] , name , key ) end end end
Define a method that forwards the key to the receiver.
Define a method that forwards the key to the receiver .
None
void
receiver
message receiver that have method #[]
message receiver that have method # []
key
key that we forward to the receiver
key that we forward to the receiver
name
method name that we forward from
method name that we forward from