Class: ImportDistribution
- Inherits:
-
ApplicationRecord
show all
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/import_distribution.rb,
app/models/import_distribution/csv_header_validator.rb
Overview
Defined Under Namespace
Classes: CsvHeaderValidator
Instance Method Summary
collapse
Instance Method Details
#run! ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'app/models/import_distribution.rb', line 45
def run!
ImportDistributionsRunJob.perform_later(self)
state_machine.transition_to!(:imported)
save
end
|
#set_csv_file_attributes ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/models/import_distribution.rb', line 33
def set_csv_file_attributes
parsed = CSV.parse(csv_file.download)
update_columns(
headers: parsed[0],
row_count: parsed.size - 1,
content_type: csv_file.content_type.to_s,
filename: csv_file.filename.to_s,
extension: csv_file.filename.extension.to_s
)
end
|
#state_machine ⇒ Object
29
30
31
|
# File 'app/models/import_distribution.rb', line 29
def state_machine
@state_machine ||= ImportDistributionStateMachine.new(self, transition_class: ImportDistributionTransition)
end
|