On 2/2/06, Daniel Berger <Daniel.Berger / qwest.com> 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
> }

I'm guessing it's because you've already got a variable holding the
store, so obviously you can just use that in the block. This is
different from say File.open where that method call is creating the
object you want to operate on inside the block that follows it. Of
course you might write a method that returns the store to you and want
to invoke a transaction on it. For example,

get_store("some-store-lookup-key").transaction do |store|
  # do something with store here
end

In this case I can see where your suggestion would be nice to have.

--
R. Mark Volkmann
Partner, Object Computing, Inc.