Class: Tortoise::BulkLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/tortoise/services/bulk_loader.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files) ⇒ BulkLoader

Returns a new instance of BulkLoader.



5
6
7
# File 'lib/tortoise/services/bulk_loader.rb', line 5

def initialize(files)
  @files = files
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/tortoise/services/bulk_loader.rb', line 3

def files
  @files
end

Class Method Details

.load(files) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tortoise/services/bulk_loader.rb', line 9

def self.load(files)
  new(files).load
rescue StandardError => e
  puts "Um erro aconteceu!", e

  Honeybadger.notify(e, context: {
    files: files,
    configuration: Tortoise::Configuration.all.map(&:to_s),
    directories: Tortoise::Directory.all.map(&:to_s),
    version: Tortoise::VERSION
  }) unless ENV['TORTOISE_HONEYBADGER_API_KEY'].to_s.empty?
end

Instance Method Details

#loadObject



22
23
24
25
26
# File 'lib/tortoise/services/bulk_loader.rb', line 22

def load
  files.each do |file|
    Tortoise::Loader.load(file)
  end
end