From: Dave Thomas Date: 2001-02-23T10:33:06+09:00 Subject: [ruby-talk:11358] Re: binding to callers namespace. "Joseph McDonald" writes: > Am I using caller wrong here? 'fraid so. Caller returns an array containing the call stack, not the object that is the caller. You _could_ do something similar to what you want though, using eval. The code below shows two ways to get the binding: both involve cooperation on behalf of the caller: class Object public :binding end class Display def initialize(aBinding) @binding = aBinding end def render puts "secret is #{eval '@secret', @binding } var is #{eval 'var',@binding}" end end class Display2 def render(&binding) puts "secret is #{eval '@secret', binding } var is #{eval 'var', binding}" end end class Demo def initialize(n) @secret = n end def display var = "asdf" d = Display.new(binding) d.render # want to give it access to @secret and "var" d = Display2.new d.render {} end end k1 = Demo.new(99) k1.display However, you might want to think about alternative designs to get the same effect... this is going to get messy pretty quickly :) Regards Dave