Class: Mortymer::Types::RackFile

Inherits:
Object
  • Object
show all
Defined in:
lib/mortymer/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tempfile:, original_filename:, content_type:) ⇒ RackFile

Returns a new instance of RackFile.



12
13
14
15
16
# File 'lib/mortymer/types.rb', line 12

def initialize(tempfile:, original_filename:, content_type:)
  @tempfile = tempfile
  @original_filename = original_filename
  @content_type = content_type
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



10
11
12
# File 'lib/mortymer/types.rb', line 10

def content_type
  @content_type
end

#original_filenameObject (readonly)

Returns the value of attribute original_filename.



10
11
12
# File 'lib/mortymer/types.rb', line 10

def original_filename
  @original_filename
end

#tempfileObject (readonly)

Returns the value of attribute tempfile.



10
11
12
# File 'lib/mortymer/types.rb', line 10

def tempfile
  @tempfile
end

Class Method Details

.new_from_rack_file(file) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/mortymer/types.rb', line 18

def self.new_from_rack_file(file)
  return nil if file.nil?

  new(
    tempfile: file.respond_to?(:tempfile) ? file.tempfile : file[:tempfile],
    original_filename: file.respond_to?(:original_filename) ? file.original_filename : file[:original_filename],
    content_type: file.respond_to?(:content_type) ? file.content_type : file[:content_type]
  )
end