Skip to content

Commit

Permalink
Merge pull request #141 from atambo/params_encoding_none
Browse files Browse the repository at this point in the history
Add params_encoding :none
  • Loading branch information
hanshasselberg committed May 14, 2018
2 parents bd29403 + 3c6c1cb commit de60a72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ethon/easy/queryable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def recursively_generate_pairs(h, prefix, pairs)
encode_rack_array_pairs(h, prefix, pairs)
elsif params_encoding == :multi
encode_multi_array_pairs(h, prefix, pairs)
elsif params_encoding == :none
pairs << [prefix, h]
else
encode_indexed_array_pairs(h, prefix, pairs)
end
Expand All @@ -128,7 +130,7 @@ def encode_rack_array_pairs(h, prefix, pairs)
pairs_for(v, key, pairs)
end
end

def encode_multi_array_pairs(h, prefix, pairs)
h.each_with_index do |v, i|
key = prefix
Expand Down
8 changes: 8 additions & 0 deletions spec/ethon/easy/queryable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@
expect(pairs).to include(["b[]", 3])
end
end

context "when params_encoding is :none" do
before { params.params_encoding = :none }
it "does no transformation" do
expect(pairs).to include([:a, 1])
expect(pairs).to include([:b, [2, 3]])
end
end
end

context "when params contains something nested in an array" do
Expand Down

0 comments on commit de60a72

Please sign in to comment.