Bug #5305
closedYAML::DBM#update、#replace のコメントの間違いを修正する
Description
YAML::DBM#update、#replace のコメントに each メソッドや each_pair
メソッドがあれば引数として指定できる旨の記述がありますが、実際には
keys.each しているため、正しくないようです。
Updated by ayumin (Ayumu AIZAWA) over 13 years ago
- ruby -v changed from ruby 1.9.4dev (2011-09-10 trunk 33240) [x86_64-linux] to -
Hi Guys,
The comments of YAML::DBM#update and #replace says it requires only
'each and each_pair', but they are using 'keys.each' actually.
I think the comment should be modified, so I hope someone provide a draft.
Following is the original comment of YAML#update and #replace:
#update:
"Updates the database with multiple values from the specified object.
Takes any object which implements the each_pair method, including Hash
and DBM objects. Returns +self+."
#replace:
"Replaces the contents of the database with the contents of the
specified object.
Takes any object which implements the each_pair method, including Hash and
DBM objects."
Regards
Ayumu AIZAWA
Updated by ayumin (Ayumu AIZAWA) about 13 years ago
- Assignee set to ayumin (Ayumu AIZAWA)
- Target version set to 2.0.0
- ruby -v changed from - to ruby 1.9.4dev (2011-09-19 trunk 33297) [x86_64-linux]
I think, YAML::DBM#update be able to rewrite without #keys.
--- lib/yaml/dbm.rb
+++ lib/yaml/dbm.rb
@@ -185,8 +185,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|
-
endself.store( k, v ) end self
But there are no test for YAML::DBM, so I'm writing test for these now.
After my work, this issue would be closed.
Updated by ayumin (Ayumu AIZAWA) about 13 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r33329.
Sho, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- lib/yaml/dbm/dbm.rb: fix #update, add #key for using istead #index.
[Bug #5305][ruby-dev:44485]