mardi 3 novembre 2015

Get info of ruby variable inside a block

I have a method like

def my_method(&block)
     begin
       yield 
     rescue Exception => e
       puts "Exception"
       return
     end 
 end

And the method is called for 2 global variables.

my_method { $memcache_connection1.get(key) }
my_method { $memcache_connection2.get(key) }

Inside my_method, I have no way to identify for which memcache connection it is called for. It is simply yielding the block passed.

I need to know which memcache connection is used inside my_method. Is this possible?

Aucun commentaire:

Enregistrer un commentaire