Class: Tessa::Upload::UploadsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/tessa/upload/uploads_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(upload:, connection: self.class.connection_factory) ⇒ UploadsFile

Returns a new instance of UploadsFile.



4
5
6
7
# File 'lib/tessa/upload/uploads_file.rb', line 4

def initialize(upload:, connection: self.class.connection_factory)
  @upload = upload
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



2
3
4
# File 'lib/tessa/upload/uploads_file.rb', line 2

def connection
  @connection
end

#uploadObject (readonly)

Returns the value of attribute upload.



2
3
4
# File 'lib/tessa/upload/uploads_file.rb', line 2

def upload
  @upload
end

Class Method Details

.connection_factoryObject



15
16
17
# File 'lib/tessa/upload/uploads_file.rb', line 15

def self.connection_factory
  Tessa::FakeConnection.new
end

Instance Method Details

#call(file) ⇒ Object



9
10
11
12
13
# File 'lib/tessa/upload/uploads_file.rb', line 9

def call(file)
  connection
    .public_send(upload.upload_method, upload.upload_url, File.read(file))
    .success?
end