Class: MetadataPresenter::FileUploader

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/metadata_presenter/file_uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



4
5
6
# File 'app/models/metadata_presenter/file_uploader.rb', line 4

def adapter
  @adapter
end

#componentObject

Returns the value of attribute component.



4
5
6
# File 'app/models/metadata_presenter/file_uploader.rb', line 4

def component
  @component
end

#page_answersObject

Returns the value of attribute page_answers.



4
5
6
# File 'app/models/metadata_presenter/file_uploader.rb', line 4

def page_answers
  @page_answers
end

#sessionObject

Returns the value of attribute session.



4
5
6
# File 'app/models/metadata_presenter/file_uploader.rb', line 4

def session
  @session
end

Instance Method Details

#file_detailsObject



20
21
22
# File 'app/models/metadata_presenter/file_uploader.rb', line 20

def file_details
  page_answers.send(component.id)
end

#uploadObject



6
7
8
# File 'app/models/metadata_presenter/file_uploader.rb', line 6

def upload
  UploadedFile.new(file: upload_file, component: component)
end

#upload_fileObject



10
11
12
13
14
15
16
17
18
# File 'app/models/metadata_presenter/file_uploader.rb', line 10

def upload_file
  return {} if file_details.blank?

  adapter.new(
    session: session,
    file_details: file_details,
    allowed_file_types: component.validation['accept']
  ).call
end