map 2.6.1 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/map.rb +4 -2
- data/map.gemspec +1 -1
- data/test/map_test.rb +6 -0
- metadata +5 -5
data/lib/map.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Map < Hash
|
2
|
-
Version = '2.
|
2
|
+
Version = '2.7.0' unless defined?(Version)
|
3
3
|
Load = Kernel.method(:load) unless defined?(Load)
|
4
4
|
|
5
5
|
class << Map
|
@@ -567,7 +567,9 @@ class Map < Hash
|
|
567
567
|
self[key] = value
|
568
568
|
else
|
569
569
|
key = method
|
570
|
-
|
570
|
+
unless has_key?(key)
|
571
|
+
return(block ? fetch(*args, &block) : super(*args))
|
572
|
+
end
|
571
573
|
self[key]
|
572
574
|
end
|
573
575
|
end
|
data/map.gemspec
CHANGED
data/test/map_test.rb
CHANGED
@@ -290,6 +290,12 @@ Testing Map do
|
|
290
290
|
assert{ m.key == :val }
|
291
291
|
end
|
292
292
|
|
293
|
+
testing 'that method missing with a block delegatets to fetch' do
|
294
|
+
m = Map.new
|
295
|
+
assert{ m.key{ :val } == :val }
|
296
|
+
assert{ !m.has_key?(:key) }
|
297
|
+
end
|
298
|
+
|
293
299
|
testing 'that #id werks' do
|
294
300
|
m = Map.new
|
295
301
|
assert{ (m.id rescue $!).is_a?(Exception) }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 2.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ara T. Howard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|