On Fri, 3 Feb 2006, Daniel Berger wrote:

> Hi all,
>
> This is one of those, "Why are things this way" kind of questions.
>
> Why doesn't PStore#transaction yield itself?  That way I could write:
>
> store.transaction{ |s|
>   s['names'] = %w/foo bar baz/
>   s['tree']  = T.new
> }

hmmm.

   harp:~ > ruby -r pstore -e ' PStore::new("ps").transaction{|ps| p ps.class} '
   PStore

   harp:~ > ruby -v
   ruby 1.8.4 (2006-01-12) [i686-linux]


   jib:~ > ruby -r pstore -e ' PStore::new("ps").transaction{|ps| p ps.class} '
   PStore

   jib:~ > ruby -v
   ruby 1.8.1 (2003-12-25) [i686-linux]

seems to for me?  is that what you meant.


> Or maybe we could even use method_missing to clean things up even more:
>
> store.transaction{ |s|
>   s.names = %w/foo bar baz/ # same as s['names']
>   s.tree  = T.new
> }

that would be a nice hack for string keys - of course keys don't have to be
keys but i bet they are 99% of the time.  good idea.  submit a patch!  ;-)

cheers.

-a

-- 
happiness is not something ready-made.  it comes from your own actions.
- h.h. the 14th dali lama