summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-25 12:05:02 +0000
committerayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-25 12:05:02 +0000
commit73bd9e566b081941e9e7f158cbf4f5fd1c2461a8 (patch)
tree5862b0226dda072b1ccb40539024fdd06562ea49 /lib
parentfecda0d9f72f52f9777fb32f63eb2471353221ec (diff)
* lib/yaml/dbm/dbm.rb: fix #update, add #key for using istead #index.
[Bug #5305][ruby-dev:44485] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/yaml/dbm.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/yaml/dbm.rb b/lib/yaml/dbm.rb
index 07441f53ad..976fdb3bb6 100644
--- a/lib/yaml/dbm.rb
+++ b/lib/yaml/dbm.rb
@@ -57,10 +57,20 @@ class DBM < ::DBM
end
# Deprecated, used YAML::DBM#key instead.
+ # ----
+ # Note:
+ # YAML::DBM#index makes warning from internal of ::DBM#index.
+ # It says 'DBM#index is deprecated; use DBM#key', but DBM#key
+ # behaves not same as DBM#index.
+ #
def index( keystr )
super( keystr.to_yaml )
end
+ def key( keystr )
+ invert[keystr]
+ end
+
# Returns an array containing the values associated with the given keys.
def values_at( *keys )
keys.collect { |k| fetch( k ) }
@@ -185,8 +195,8 @@ class DBM < ::DBM
#
# Returns +self+.
def update( hsh )
- hsh.keys.each do |k|
- self.store( k, hsh.fetch( k ) )
+ hsh.each_pair do |k,v|
+ self.store( k, v )
end
self
end