I'm probably missing something obvious, but...

I'm trying to create a block within a class definition that can be
bound to instances of the class, not the class itself. This code
obviously doesn't work:

     class Dave
       @@block = proc { puts @name }
       @name = "class level"
       def initialize
         @name = "instance level"
       end

       def block
         @@block.call
       end
     end

     Dave.new.block

It will always output "class level" as @name is bound at the time the
block is created. Is there any way to change that binding at runtime
so that I can call the block and have it output "instance level"?



Dave