map 6.4.1 → 6.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/map.rb +1 -1
- data/lib/map/params.rb +10 -0
- data/map.gemspec +1 -1
- data/test/map_test.rb +3 -0
- metadata +1 -1
data/lib/map.rb
CHANGED
data/lib/map/params.rb
CHANGED
@@ -30,6 +30,16 @@ class Map
|
|
30
30
|
param_for(*args, &block)
|
31
31
|
end
|
32
32
|
|
33
|
+
def to_params
|
34
|
+
to_params = Array.new
|
35
|
+
|
36
|
+
depth_first_each do |key, val|
|
37
|
+
to_params.push(param_for(key))
|
38
|
+
end
|
39
|
+
|
40
|
+
to_params.join('&')
|
41
|
+
end
|
42
|
+
|
33
43
|
module Param
|
34
44
|
def param_for(value, prefix = nil)
|
35
45
|
case value
|
data/map.gemspec
CHANGED
data/test/map_test.rb
CHANGED
@@ -748,6 +748,9 @@ Testing Map do
|
|
748
748
|
assert{ m.name_for(:A, :B, :C) == 'map[A][B][C]' }
|
749
749
|
|
750
750
|
assert{ m.name_for(:A, :B, :C, :prefix => :foo) == 'foo[A][B][C]' }
|
751
|
+
|
752
|
+
m = Map.for({"a"=>{"b"=>42}, "x"=>{"y"=>42}, "foo"=>:bar, "array"=>[{"k"=>:v}]})
|
753
|
+
assert{ m.to_params == "map[a][b]=42&map[x][y]=42&map[foo]=bar&map[array][][k]=v" }
|
751
754
|
end
|
752
755
|
|
753
756
|
testing 'delete_if' do
|