Class: Renalware::UKRDC::Incoming::ImportSurveys

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/ukrdc/incoming/import_surveys.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths: nil, logger: nil) ⇒ ImportSurveys

Returns a new instance of ImportSurveys.



13
14
15
16
17
# File 'app/models/renalware/ukrdc/incoming/import_surveys.rb', line 13

def initialize(paths: nil, logger: nil)
  @paths = paths || Renalware::UKRDC::Incoming::Paths.new
  @logger = logger || Rails.logger
  @batch_uuid = SecureRandom.uuid # to group logging output
end

Instance Attribute Details

#batch_uuidObject (readonly)

Returns the value of attribute batch_uuid.



11
12
13
# File 'app/models/renalware/ukrdc/incoming/import_surveys.rb', line 11

def batch_uuid
  @batch_uuid
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
# File 'app/models/renalware/ukrdc/incoming/import_surveys.rb', line 19

def call
  Incoming::FileList.new(paths: paths).each_file do |filepath|
    import_surveys_from_file(filepath)
  end
rescue StandardError => e
  Renalware::Engine.exception_notifier.notify(e)
  raise e
end