Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit 73bfb10

Browse files
committed
Use Forwardable over silly method defs that do just that
1 parent e4b1e7b commit 73bfb10

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

lib/we_transfer/mini_io.rb

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ module WeTransfer
22
# Wrapper around an IO object, delegating only methods we need for creating
33
# and sending a file in chunks.
44
#
5-
65
class MiniIO
6+
extend Forwardable
7+
78
def self.mini_io_able?(io)
89
return false if io.is_a? WeTransfer::NullMiniIO
910

@@ -38,28 +39,6 @@ def initialize(io)
3839
@io.rewind
3940
end
4041

41-
def read(*args)
42-
@io.read(*args)
43-
end
44-
45-
def rewind
46-
@io.rewind
47-
end
48-
49-
def seek(*args)
50-
@io.seek(*args)
51-
end
52-
53-
# The size, delegated to io.
54-
#
55-
# nil is fine, since this method is used only as the default size for a
56-
# WeTransferFile
57-
# @returns [Integer] the size of the io
58-
#
59-
def size
60-
@io.size
61-
end
62-
6342
# The name of the io, guessed using File.basename. If this raises a TypeError
6443
# we swallow the error, since this is used only as the default name for a
6544
# WeTransferFile
@@ -70,6 +49,8 @@ def name
7049
# yeah, what?
7150
end
7251

52+
def_delegators :@io, :read, :rewind, :seek, :size
53+
7354
private
7455

7556
def ensure_mini_io_able!(io)

0 commit comments

Comments
 (0)