Class: Workarea::Reports::Export
Instance Method Summary
collapse
#releasable?
assert_valid_config!, async, disable, enable, inline, #run_callbacks
#embedded_children
Instance Method Details
#name ⇒ Object
28
29
30
|
# File 'app/models/workarea/reports/export.rb', line 28
def name
report_type.titleize
end
|
#process! ⇒ Object
32
33
34
35
36
|
# File 'app/models/workarea/reports/export.rb', line 32
def process!
set(started_at: Time.current)
CSV.open(temp_path, 'w') { |csv| yield(csv) }
update_attributes!(file: temp_path, completed_at: Time.current)
end
|
#report ⇒ Object
38
39
40
41
|
# File 'app/models/workarea/reports/export.rb', line 38
def report
klass = "Workarea::Reports::#{report_type.camelize}".constantize
report = klass.new(report_params)
end
|
#temp_path ⇒ Object
43
44
45
46
47
|
# File 'app/models/workarea/reports/export.rb', line 43
def temp_path
@temp_path ||= Pathname
.new(Dir.tmpdir)
.join("#{report_type}_#{Time.current.to_s(:export)}.csv")
end
|