@@ -70,13 +70,11 @@ def primitive?(input)
7070
7171 # @api private
7272 #
73- # @param input [Object ]
73+ # @param input [String, Boolean ]
7474 #
7575 # @return [Boolean, Object]
7676 def coerce_boolean ( input )
7777 case input . is_a? ( String ) ? input . downcase : input
78- in Numeric
79- input . nonzero?
8078 in "true"
8179 true
8280 in "false"
@@ -88,7 +86,7 @@ def coerce_boolean(input)
8886
8987 # @api private
9088 #
91- # @param input [Object ]
89+ # @param input [String, Boolean ]
9290 #
9391 # @raise [ArgumentError]
9492 # @return [Boolean, nil]
@@ -103,34 +101,20 @@ def coerce_boolean!(input)
103101
104102 # @api private
105103 #
106- # @param input [Object ]
104+ # @param input [String, Integer ]
107105 #
108106 # @return [Integer, Object]
109107 def coerce_integer ( input )
110- case input
111- in true
112- 1
113- in false
114- 0
115- else
116- Integer ( input , exception : false ) || input
117- end
108+ Integer ( input , exception : false ) || input
118109 end
119110
120111 # @api private
121112 #
122- # @param input [Object ]
113+ # @param input [String, Integer, Float ]
123114 #
124115 # @return [Float, Object]
125116 def coerce_float ( input )
126- case input
127- in true
128- 1.0
129- in false
130- 0.0
131- else
132- Float ( input , exception : false ) || input
133- end
117+ Float ( input , exception : false ) || input
134118 end
135119
136120 # @api private
@@ -159,12 +143,7 @@ class << self
159143 private def deep_merge_lr ( lhs , rhs , concat : false )
160144 case [ lhs , rhs , concat ]
161145 in [ Hash , Hash , _ ]
162- rhs_cleaned = rhs . reject { _2 == Orb ::Internal ::OMIT }
163- lhs
164- . reject { |key , _ | rhs [ key ] == Orb ::Internal ::OMIT }
165- . merge ( rhs_cleaned ) do |_ , old_val , new_val |
166- deep_merge_lr ( old_val , new_val , concat : concat )
167- end
146+ lhs . merge ( rhs ) { deep_merge_lr ( _2 , _3 , concat : concat ) }
168147 in [ Array , Array , true ]
169148 lhs . concat ( rhs )
170149 else
@@ -362,7 +341,7 @@ def normalized_headers(*headers)
362341 value =
363342 case val
364343 in Array
365- val . map { _1 . to_s . strip } . join ( ", " )
344+ val . filter_map { _1 & .to_s & .strip } . join ( ", " )
366345 else
367346 val &.to_s &.strip
368347 end
@@ -469,7 +448,7 @@ class << self
469448 case val
470449 in IO
471450 y << "Content-Type: application/octet-stream\r \n \r \n "
472- IO . copy_stream ( val , y )
451+ IO . copy_stream ( val . tap ( & :rewind ) , y )
473452 in StringIO
474453 y << "Content-Type: application/octet-stream\r \n \r \n "
475454 y << val . string
@@ -533,6 +512,8 @@ def encode_content(headers, body)
533512 boundary , strio = encode_multipart_streaming ( body )
534513 headers = { **headers , "content-type" => "#{ content_type } ; boundary=#{ boundary } " }
535514 [ headers , strio ]
515+ in [ _ , IO ]
516+ [ headers , body . tap ( &:rewind ) ]
536517 in [ _ , StringIO ]
537518 [ headers , body . string ]
538519 else
@@ -673,7 +654,7 @@ def decode_lines(enum)
673654 #
674655 # @param lines [Enumerable<String>]
675656 #
676- # @return [Hash{Symbol=>Object}]
657+ # @return [Enumerable< Hash{Symbol=>Object}> ]
677658 def decode_sse ( lines )
678659 # rubocop:disable Metrics/BlockLength
679660 chain_fused ( lines ) do |y |
0 commit comments