lib/httpx/transcoder/body.rb in httpx-0.17.0 vs lib/httpx/transcoder/body.rb in httpx-0.18.0
- old
+ new
@@ -7,10 +7,11 @@
class Error < HTTPX::Error; end
module_function
class Encoder
+ using HTTPX::ArrayExtensions
extend Forwardable
def_delegator :@raw, :to_s
def initialize(body)
@@ -19,10 +20,10 @@
def bytesize
if @raw.respond_to?(:bytesize)
@raw.bytesize
elsif @raw.respond_to?(:to_ary)
- @raw.map(&:bytesize).reduce(0, :+)
+ @raw.sum(&:bytesize)
elsif @raw.respond_to?(:size)
@raw.size || Float::INFINITY
elsif @raw.respond_to?(:length)
@raw.length || Float::INFINITY
elsif @raw.respond_to?(:each)