Class: ForemanInventoryUpload::Async::UploadReportDirectJob::FileUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman_inventory_upload/async/upload_report_direct_job.rb

Overview

Wrapper class to avoid monkey-patching File for multipart uploads

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, content_type:) ⇒ FileUpload



15
16
17
18
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 15

def initialize(file, content_type:)
  @file = file
  @content_type = content_type
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 32

def method_missing(method_name, *args, &block)
  if @file.respond_to?(method_name)
    @file.send(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



13
14
15
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 13

def content_type
  @content_type
end

#fileObject (readonly)

Returns the value of attribute file.



13
14
15
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 13

def file
  @file
end

Instance Method Details

#pathObject



24
25
26
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 24

def path
  @file.path
end

#read(*args) ⇒ Object



20
21
22
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 20

def read(*args)
  @file.read(*args)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean



28
29
30
# File 'lib/foreman_inventory_upload/async/upload_report_direct_job.rb', line 28

def respond_to_missing?(method_name, include_private = false)
  @file.respond_to?(method_name, include_private) || super
end