Permalink
Browse files

preserve Array-y classes when coercing

  • Loading branch information...
1 parent 4fe71de commit 767361fbaa12099c3a4048186371a1523297536a @ahoward committed Jun 30, 2012
Showing with 13 additions and 5 deletions.
  1. +2 −2 lib/map.rb
  2. +3 −3 map.gemspec
  3. +8 −0 test/map_test.rb
View
@@ -1,6 +1,6 @@
# -*- encoding : utf-8 -*-
class Map < Hash
- Version = '6.1.0' unless defined?(Version)
+ Version = '6.2.0' unless defined?(Version)
Load = Kernel.method(:load) unless defined?(Load)
class << Map
@@ -262,7 +262,7 @@ def self.convert_value(value)
when Hash
coerce(value)
when Array
- value.map{|v| convert_value(v)}
+ value.map!{|v| convert_value(v)}
else
value
end
View
@@ -3,7 +3,7 @@
Gem::Specification::new do |spec|
spec.name = "map"
- spec.version = "6.0.0"
+ spec.version = "6.2.0"
spec.platform = Gem::Platform::RUBY
spec.summary = "map"
spec.description = "description: map kicks the ass"
@@ -12,11 +12,11 @@ Gem::Specification::new do |spec|
["LICENSE",
"README",
"Rakefile",
- "TODO",
- "a.rb",
"lib",
"lib/map",
"lib/map.rb",
+ "lib/map/integrations",
+ "lib/map/integrations/active_record.rb",
"lib/map/options.rb",
"lib/map/struct.rb",
"map.gemspec",
View
@@ -727,6 +727,14 @@ def o.to_map() {:k => :v} end
end
end
+ testing 'that Array-y values preserve their class' do
+ map = Map.new
+ list = Class.new(Array){}.new
+ map.list = list
+ assert{ map.list.class == list.class }
+ assert{ map.list.class != Array }
+ end
+
protected
def new_int_map(n = 1024)
map = assert{ Map.new }

0 comments on commit 767361f

Please sign in to comment.