diff options
| author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-05 05:28:11 +0000 |
|---|---|---|
| committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-05 05:28:11 +0000 |
| commit | 0b4f8a72d8b81466ca422bf3d88e7c181e632dff (patch) | |
| tree | 6bbcd5e080f42788b941f0f0b58a6a5aec5fbcbb /lib | |
| parent | 7af5d4279727dac6b9922fb06343fcf9f2fdd4eb (diff) | |
| download | ruby-0b4f8a72d8b81466ca422bf3d88e7c181e632dff.tar.gz ruby-0b4f8a72d8b81466ca422bf3d88e7c181e632dff.tar.xz ruby-0b4f8a72d8b81466ca422bf3d88e7c181e632dff.zip | |
* lib/pstore.rb: should return default value if name is not found.
[ruby-core:7304]
* lib/pstore.rb: should raise PStore::Error if not in transaction.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pstore.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb index a691ce611..46123bf0a 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -135,14 +135,15 @@ class PStore # raise PStore::Error if called at any other time. # def fetch(name, default=PStore::Error) + in_transaction unless @table.key? name if default==PStore::Error raise PStore::Error, format("undefined root name `%s'", name) else - default + return default end end - self[name] + @table[name] end # # Stores an individual Ruby object or a hierarchy of Ruby objects in the data |
