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

#adapter ⇒ Object

Returns the value of attribute adapter.



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

def adapter
  @adapter
end

#component ⇒ Object

Returns the value of attribute component.



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

def component
  @component
end

#page_answers ⇒ Object

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

#session ⇒ Object

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_details ⇒ Object



20
21
22
23
24
25
26
# File 'app/models/metadata_presenter/file_uploader.rb', line 20

def file_details
  if component.multiupload?
    return page_answers.send(component.id)[component.id].last
  end

  page_answers.send(component.id)
end

#upload ⇒ Object



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

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

#upload_file ⇒ Object



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:,
    file_details:,
    allowed_file_types: component.validation['accept']
  ).call
end