Minor Change Proposal for Classes 'Object' and 'Method'
_______________________________________________________


I would like to make a small change suggestion on the class 'Method' by which 
the method 'Object#method' is also affected.

Background:
___________

When creating a 'Method' object, it is not possible to receive the object 
identification of the object which uses the 'Object#method' method (see 'Example 
for Workaround' for details) by using some Method of class 'Method'.

It is useful for some applications to analyse later on which to which objects a 
method is bound in an object of class 'Method'. In addition, it is simply 
missing from my viewpoint, because it is an essential information (attribute) of 
an object of class 'Method'.

A minor wish is an additional method for class 'Method', which returns the 
contents of 'Method#to_s' as an Array containing two elements, the class-name 
and the method-name without the textual border of 'Method#to_s'. It is easier 
and less expensive to return this existing information by a method of class 
'Method', than to use a regular expression later on to extract the information.

The method names used by here are only suggestions, since I needed names for the 
example. Regarding definite names I have no emotions.

___________


 >>>>> Example for Workaround >>>>>
class Object
   alias :_org_method :method
   def method(name)
     method_object = self._org_method(name)
     method_object.instance_id = self.object_id
     method_object
   end
end

class Method
   attr_accessor :instance_id
   def method_name
     md = self.to_s.match(/Method:\s*([^#]+)#([^>]+)>/)
     return md[1], md[2]
   end
end

# Now an example

class Hugo
   def hi
     puts "An instance of Hugo says 'Hi!'"
   end
end

my_hugo = Hugo.new
puts my_hugo.object_id     # => 22497820 (for example)
myhi = my_hugo.method(:hi)
myhi[]                     # => An instance of Hugo says 'Hi!'
puts myhi.instance_id      # => 22497820 (for example)
p myhi.method_name         # => ["Hugo", "hi"]
 >>>>>     End of Example     >>>>>

___________


Please inform me, if this is not the right place for a change proposal.

Wolfgang N?dasi-Donner (WoN?Do)