Skip to content

Commit 3083334

Browse files
committed
Use keyword argument for encoder in HTTP::FormData::Urlencoded#initialize for consistency
1 parent 0384419 commit 3083334

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/http/form_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def create(data, encoder: nil)
4747
if multipart?(data)
4848
Multipart.new(data)
4949
else
50-
Urlencoded.new(data, encoder)
50+
Urlencoded.new(data, encoder: encoder)
5151
end
5252
end
5353

lib/http/form_data/urlencoded.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def encoder
6363
end
6464

6565
# @param [#to_h, Hash] data form data key-value Hash
66-
def initialize(data, encoder = nil)
66+
def initialize(data, encoder: nil)
6767
encoder ||= self.class.encoder
6868
@io = StringIO.new(encoder.call(FormData.ensure_hash(data)))
6969
end

spec/lib/http/form_data/urlencoded_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
context "with custom instance level encoder" do
6969
let(:encoder) { proc { |data| ::JSON.dump(data) } }
70-
subject(:form_data) { HTTP::FormData::Urlencoded.new(data, encoder) }
70+
subject(:form_data) { HTTP::FormData::Urlencoded.new(data, encoder: encoder) }
7171

7272
it "uses encoder passed to initializer" do
7373
expect(form_data.to_s).to eq('{"foo[bar]":"test"}')

0 commit comments

Comments
 (0)