map 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/map.rb +8 -2
  2. data/test/map_test.rb +7 -0
  3. metadata +4 -4
data/lib/map.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Map < Hash
2
- Version = '2.0.0' unless defined?(Version)
2
+ Version = '2.1.0' unless defined?(Version)
3
3
  Load = Kernel.method(:load) unless defined?(Load)
4
4
 
5
5
  class << Map
@@ -502,7 +502,8 @@ class Map < Hash
502
502
  def with_indifferent_access!; self end
503
503
  def with_indifferent_access; dup end
504
504
 
505
- # a sane method missing that only supports reading previously set values
505
+ # a sane method missing that only supports writing values or reading
506
+ # *previously set* values
506
507
  #
507
508
  def method_missing(method, *args, &block)
508
509
  method = method.to_s
@@ -518,6 +519,11 @@ class Map < Hash
518
519
  end
519
520
  end
520
521
 
522
+ def id
523
+ raise NoMethodError unless has_key?(:id)
524
+ self[:id]
525
+ end
526
+
521
527
  # support for compound key indexing and depth first iteration
522
528
  #
523
529
  def get(*keys)
data/test/map_test.rb CHANGED
@@ -262,6 +262,13 @@ Testing Map do
262
262
  assert{ m.key == :val }
263
263
  end
264
264
 
265
+ testing 'that #id werks' do
266
+ m = Map.new
267
+ assert{ (m.id rescue $!).is_a?(Exception) }
268
+ m.id = 42
269
+ assert{ m.id==42 }
270
+ end
271
+
265
272
  testing 'that maps support compound key/val setting' do
266
273
  m = Map.new
267
274
  assert{ m.set(:a, :b, :c, 42) }
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: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 2.0.0
10
+ version: 2.1.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: 2010-12-24 00:00:00 -07:00
18
+ date: 2011-01-05 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21