summaryrefslogtreecommitdiff
path: root/lib/pstore.rb
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-05 05:28:11 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-05 05:28:11 +0000
commitc44118b8a0dad1cef18f3294e15f15509e66e9e8 (patch)
tree199a86ddb13acf390231e4664a98e060a5c43f89 /lib/pstore.rb
parent914e4d244fee32fa145d186f8e0a0e069085a298 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pstore.rb')
-rw-r--r--lib/pstore.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb
index a691ce6..46123bf 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