Skip to content

Commit f62d185

Browse files
fix: make a typo for FilePart.content
1 parent 3e0fd9e commit f62d185

4 files changed

Lines changed: 42 additions & 16 deletions

File tree

lib/orb/file_part.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class FilePart
1515
#
1616
# @return [String]
1717
private def read
18-
case contents
18+
case content
1919
in Pathname
20-
contents.read(binmode: true)
20+
content.read(binmode: true)
2121
in StringIO
22-
contents.string
22+
content.string
2323
in IO
24-
contents.read
24+
content.read
2525
in String
26-
contents
26+
content
2727
end
2828
end
2929

lib/orb/internal/type/converter.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def dump(value, state:)
4444
in Pathname | IO
4545
state[:can_retry] = false if value.is_a?(IO)
4646
Orb::FilePart.new(value)
47+
in Orb::FilePart
48+
state[:can_retry] = false if value.content.is_a?(IO)
49+
value
4750
else
4851
value
4952
end

lib/orb/internal/type/file_input.rb

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,28 @@ def coerce(value, state:)
6666
end
6767
end
6868

69-
# @!parse
70-
# # @api private
71-
# #
72-
# # @param value [Pathname, StringIO, IO, String, Object]
73-
# #
74-
# # @param state [Hash{Symbol=>Object}] .
75-
# #
76-
# # @option state [Boolean] :can_retry
77-
# #
78-
# # @return [Pathname, StringIO, IO, String, Object]
79-
# def dump(value, state:) = super
69+
# @api private
70+
#
71+
# @param value [Pathname, StringIO, IO, String, Object]
72+
#
73+
# @param state [Hash{Symbol=>Object}] .
74+
#
75+
# @option state [Boolean] :can_retry
76+
#
77+
# @return [Pathname, StringIO, IO, String, Object]
78+
def dump(value, state:)
79+
# rubocop:disable Lint/DuplicateBranch
80+
case value
81+
in IO
82+
state[:can_retry] = false
83+
in Orb::FilePart if value.content.is_a?(IO)
84+
state[:can_retry] = false
85+
else
86+
end
87+
# rubocop:enable Lint/DuplicateBranch
88+
89+
value
90+
end
8091
end
8192
end
8293
end

test/orb/file_part_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "test_helper"
4+
5+
class Orb::Test::FilePartTest < Minitest::Test
6+
def test_to_json
7+
text = "gray"
8+
filepart = Orb::FilePart.new(StringIO.new(text))
9+
10+
assert_equal(text.to_json, filepart.to_json)
11+
end
12+
end

0 commit comments

Comments
 (0)