Bug #5305
YAML::DBM#update、#replace のコメントの間違いを修正する
| Status: | Closed | Start date: | 09/10/2011 | |
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | 2.0.0 | |||
| ruby -v: | ruby 1.9.4dev (2011-09-19 trunk 33297) [x86_64-linux] |
Description
YAML::DBM#update、#replace のコメントに each メソッドや each_pair
メソッドがあれば引数として指定できる旨の記述がありますが、実際には
keys.each しているため、正しくないようです。
Associated revisions
* lib/yaml/dbm/dbm.rb: fix #update, add #key for using istead #index.
[Bug #5305][ruby-dev:44485]
History
Updated by ayumin (Ayumu AIZAWA) 9 months 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) 8 months 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|
+ self.store( k, v )
end
self
end
----
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) 8 months ago
- Status changed from Open to Closed
- % Done changed from 0 to 100