Class: Adrift::FileToAttach::Adapters::Rails

Inherits:
Object
  • Object
show all
Includes:
Adrift::FileToAttach::Adapter
Defined in:
lib/adrift/file_to_attach.rb

Overview

Adapter that allows to attach an uploaded file within a Rails application.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Adrift::FileToAttach::Adapter

#initialize

Class Method Details

.recognize?(file_representation) ⇒ Boolean

Indicates whether or not file_representation is an uploaded file within a Rails application.

Returns:

  • (Boolean)


53
54
55
56
# File 'lib/adrift/file_to_attach.rb', line 53

def self.recognize?(file_representation)
  file_representation.respond_to?(:original_filename) &&
    file_representation.respond_to?(:tempfile)
end

Instance Method Details

#original_filenameObject

Uploaded file’s original filename.



59
60
61
# File 'lib/adrift/file_to_attach.rb', line 59

def original_filename
  @file_representation.original_filename
end

#pathObject

Uploaded file’s path.



64
65
66
# File 'lib/adrift/file_to_attach.rb', line 64

def path
  @file_representation.tempfile.path
end