module Tins::Delegate

def delegate(method_name, opts = {})

def delegate(method_name, to: UNSET, as: method_name)
_other_method_name_ defaults to method_name, if it wasn't given.

end
delegate :method_here, :method_call, :method_there
class A
or:
end
delegate :method_here, :@obj, :method_there
class A
It's used like this:

instance variable or returned by a method call.
A method to easily delegate methods to an object, stored in an
def delegate(method_name, opts = {})
  to = opts[:to] || UNSET
  as = opts[:as] || method_name
  raise ArgumentError, "to argument wasn't defined" if to == UNSET
  to = to.to_s
  case
  when to[0, 2] == '@@'
    define_method(as) do |*args, &block|
      if self.class.class_variable_defined?(to)
        self.class.class_variable_get(to).__send__(method_name, *args, &block)
      end
    end
  when to[0] == ?@
    define_method(as) do |*args, &block|
      if instance_variable_defined?(to)
        instance_variable_get(to).__send__(method_name, *args, &block)
      end
    end
  when (?A..?Z).include?(to[0])
    define_method(as) do |*args, &block|
      Tins::DeepConstGet.deep_const_get(to).__send__(method_name, *args, &block)
    end
  else
    define_method(as) do |*args, &block|
      __send__(to).__send__(method_name, *args, &block)
    end
  end
end