Hi --

On Sun, 7 Jul 2002, Shirai,Kaoru wrote:

>  Hi.
>
> > i have a chain of objects such that one object contains another which
> > contains another, and so on, down the line. the top object recieves a
> > parameter which only the bottom most object in the chain is going to
> > need. but how do i get it down there with out passing it through all
> > the rest? and not using a global variable?
>
>  How about using Environmental Acquisition? (Came from Python.)  In
> Ruby, it is required that the package 'OBAQ' is installed. You can get
> here:
>
> http://devel.p1jp.com/snapshot/obaq-LATEST.tar.gz
>
>  Let's do same thing to Top/Middle/Bottom example.
>
>   require 'obaq/option'
>
>   class Top
>     include Obaq::Acquisition
>     def a
>       "Thanks! I need that."
>     end
>     acq_export_attr :a
>   end
>
>   class Middle
>     include Obaq::Acquisition
>   end
>
>   class Bottom
>     include Obaq::Acquisition
>     acq_import :a
>     def put_a
>       puts a
>     end
>   end
>
>   top = Top.new
>   middle = Middle.new
>   middle.set_outer(top)
>   bottom = Bottom.new
>   bottom.set_outer(middle)
>
>   bottom.put_a

Interesting, and new to me.  I'm wondering how this compares to just
putting #a in a module and mixing in the module to both Top and
Bottom -- meaning, when/why one would use E.Acquisition instead of a
module (or whether I'm wrong to see overlap in what they're doing).


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav