class Module

  # Define a shadow alias for a method.
  #
  #   class X
  #     shadow_method( :class )
  #   end
  #
  #   X.new.__class__  #=> X
  #
  def shadow_method( name, old_name=name )
    name, old_name = name.to_s, old_name.to_s
    shadow_name = '__' << name.gsub(/([=?!])$/, '') << '__' << $1.to_s
    alias_method( shadow_name, old_name )
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCModule < Test::Unit::TestCase

    class X
      shadow_method( :inspect )
    end

    def test_shadow_method
      assert( X.new.respond_to?(:__inspect__) )
    end

  end

=end
