On Jun 13, 11:23 ¨Βν¬ ΣατεεσΛανβθαναπατι Όσατεεσθ®νγ®®®ΐηναιμ®γονwrote: > >> So i Want to know which methods are invoked by my "Flower" object > > I don't understand this question. > flowerlist=Flower.new #----->Creating instance for flower > flowerlist.jasmine ------->"gives output as "iam jasmine" > flowerlist.rose =======> "gives output as "i am rose" > flowerlist.lotus #------->"Shows No Method Error" > > Question : --> My Question is i would like to know which methods are > called by object i.e flowerlist ¨ΒτθγμασΖμοχες > > if i already know those methods then > suppose if i have not define some method then i will define it > dynamically example here is "lotus" > > i think u understand my question > pleasee gave me reply I don't understand your question yet, but perhaps the following will help. If this is not what you meant, please post exactly the code you would like to write, and what results you would like from that code. module AutoMethodMaker def self.included(base) base.extend(ClassMethods) end def method_missing(method_name,*args) if self.class.maybe_make_method(method_name,*args) self.send(method_name,*args) end end module ClassMethods def methods_made @methods_made ||= [] end def auto_make_methods(pattern,&block) (@auto_make_methods ||= {})[ pattern ] = block end def maybe_make_method(method_name,*args) @auto_make_methods.each do |pattern,block| if pattern===method_name define_method(method_name,&block) methods_made << method_name return true end end end end end class Flower include AutoMethodMaker auto_make_methods /special_.+/ do puts "Special flower #{__method__[/special_(.+)/,1]}!!" end auto_make_methods /.+/ do puts "I am a #{__method__}" end def standard puts "I am a built-in method." end end f = Flower.new p Flower.methods_made #=> [] f.jasmine #=> I am a jasmine f.rose #=> I am a rose f.rose #=> I am a rose f.special_rose #=> Special flower rose!! f.standard #=> I am a built-in method. f.lotus #=> I am a lotus p Flower.methods_made #=> [:jasmine, :rose, :special_rose, :lotus]