2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/importer_helper.rb', line 2
def self.run(&block)
customer = ENV['CUSTOMER_DOMAIN']
ActiveRecord::Base.transaction do
case customer
when 'ALL'
Customer.all.each do |customer_instance|
puts "Importing for the customer \"#{customer_instance}\"..."
Uploader.set_current_domain(customer_instance.domain)
customer_instance.using_connection do
block.call
end
puts "Imported for the customer \"#{customer_instance}\""
end
when nil
block.call
else
Uploader.set_current_domain(customer)
Customer.find_by_domain(customer).using_connection do
block.call
end
puts "Imported for the customer \"#{customer}\""
end
end
end
|