Class: Saviour::LifeCycle::FileCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/saviour/life_cycle.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_path, file, column, connection) ⇒ FileCreator



4
5
6
7
8
9
# File 'lib/saviour/life_cycle.rb', line 4

def initialize(current_path, file, column, connection)
  @file = file
  @column = column
  @current_path = current_path
  @connection = connection
end

Instance Method Details

#uploadObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/saviour/life_cycle.rb', line 11

def upload
  @new_path = @file.write

  return unless @new_path

  DbHelpers.run_after_rollback(@connection) do
    uploader.storage.delete(@new_path)
  end

  [@column, @new_path]
end

#uploaderObject



23
24
25
# File 'lib/saviour/life_cycle.rb', line 23

def uploader
  @file.uploader
end