Class: ImportRedirectRules

Inherits:
Service
  • Object
show all
Defined in:
app/services/import_redirect_rules.rb

Constant Summary

Constants inherited from Service

Service::ValidationError

Instance Method Summary collapse

Methods inherited from Service

run, #run

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
15
16
# File 'app/services/import_redirect_rules.rb', line 7

def execute
  spreadsheet = Roo::Excelx.new(file.path)
  spreadsheet.each_row_streaming do |row|
    source      = row[0].value
    destination = row[1].value

    rule = RedirectorRule.where(source: path(source)).first_or_initialize
    rule.update_attributes(destination: destination, active: true)
  end
end