Sha256: 4d93b6e6a5ba77d32027cbf32686da779cffadbdce638477a95d4451e3d572de
Contents?: true
Size: 844 Bytes
Versions: 3
Compression:
Stored size: 844 Bytes
Contents
class Module # Generates a new symbol that is unique among the # inctance methods of the class/module. If a name # argument is given, it will generate a similar name. # # Class.generate_instance_method_name( :class ) => :_clast_ # def generate_instance_method_name( name='a' ) s = name.to_s while self.method_defined?( "_#{s}_" ) s = s.succ end return :"_#{s}_" end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCModule < Test::Unit::TestCase class MockObject def a ; end def b ; end def c ; end def _c ; end end def test_generate_instance_method_name assert_nothing_raised { MockObject.generate_instance_method_name(:b) } end end =end
Version data entries
3 entries across 3 versions & 1 rubygems