respond to - Trying to alias old method and create new one in ruby -


i'm using following snippet alias method if method exists:

alias_method old_name, func_name if self.respond_to? func_name 

how can error alias_method': undefined method 'get' class 'sinatra::base' (nameerror) when self.respond_to? func_name returns true?

func_name = :get in snippet

i bet call alias_method inside scope of sinatra::base. should call inside singleton class of sinatra::base, because method get defined class method.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -