Skip to content

Commit 8b2afaf

Browse files
Minor tidy up.
1 parent 0cc3f9d commit 8b2afaf

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

lib/protocol/http/header/accept.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Protocol
1212
module HTTP
1313
module Header
1414
# The `accept-content-type` header represents a list of content-types that the client can accept.
15-
class Accept < Array
15+
class Accept < Split
1616
# Regular expression used to split values on commas, with optional surrounding whitespace, taking into account quoted strings.
1717
SEPARATOR = /
1818
(?: # Start non-capturing group
@@ -83,7 +83,7 @@ def self.parse(value)
8383
def self.coerce(value)
8484
case value
8585
when Array
86-
self.new(value)
86+
self.new(value.map(&:to_s))
8787
else
8888
self.parse(value.to_s)
8989
end
@@ -96,9 +96,7 @@ def initialize(value = nil)
9696
if value.is_a?(Array)
9797
super(value)
9898
elsif value.is_a?(String)
99-
# Compatibility with the old constructor, prefer to use `parse` instead:
100-
super()
101-
self << value
99+
super(value)
102100
elsif value
103101
raise ArgumentError, "Invalid value: #{value.inspect}"
104102
end

lib/protocol/http/header/connection.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def initialize(value = nil)
3030
super(value.map(&:downcase))
3131
elsif value.is_a?(String)
3232
# Compatibility with the old constructor, prefer to use `parse` instead:
33-
super()
34-
self << value
33+
super(value)
3534
elsif value
3635
raise ArgumentError, "Invalid value: #{value.inspect}"
3736
end

lib/protocol/http/header/multiple.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def self.parse(value)
2929
def self.coerce(value)
3030
case value
3131
when Array
32-
self.new(value)
32+
self.new(value.map(&:to_s))
3333
else
3434
self.parse(value.to_s)
3535
end

lib/protocol/http/header/te.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def initialize(value = nil)
7070
super(value.map(&:downcase))
7171
elsif value.is_a?(String)
7272
# Compatibility with the old constructor, prefer to use `parse` instead:
73-
super()
74-
self << value
73+
super(value)
7574
elsif value
7675
raise ArgumentError, "Invalid value: #{value.inspect}"
7776
end

lib/protocol/http/header/transfer_encoding.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ def initialize(value = nil)
3535
super(value.map(&:downcase))
3636
elsif value.is_a?(String)
3737
# Compatibility with the old constructor, prefer to use `parse` instead:
38-
super()
39-
self << value
38+
super(value)
4039
elsif value
4140
raise ArgumentError, "Invalid value: #{value.inspect}"
4241
end

lib/protocol/http/header/vary.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def initialize(value = nil)
2020
super(value.map(&:downcase))
2121
elsif value.is_a?(String)
2222
# Compatibility with the old constructor, prefer to use `parse` instead:
23-
super()
24-
self << value
23+
super(value)
2524
elsif value
2625
raise ArgumentError, "Invalid value: #{value.inspect}"
2726
end

0 commit comments

Comments
 (0)