Class: Promethee::BlobUpgradeService

Inherits:
Object
  • Object
show all
Defined in:
app/services/promethee/blob_upgrade_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name) ⇒ BlobUpgradeService

Returns a new instance of BlobUpgradeService.



5
6
7
8
9
10
11
12
13
14
# File 'app/services/promethee/blob_upgrade_service.rb', line 5

def initialize(model_name)
  begin
    model_class = model_name.constantize
    objects = model_class.all
  rescue
    puts 'Please provide a valid model name (e.g. `rake promethee:upgrade_blob_data[Page]`)'
    exit
  end
  @objects = objects
end

Instance Attribute Details

#objectsObject

Returns the value of attribute objects.



3
4
5
# File 'app/services/promethee/blob_upgrade_service.rb', line 3

def objects
  @objects
end

Instance Method Details

#startObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/services/promethee/blob_upgrade_service.rb', line 16

def start
  puts '= START BLOB UPGRADE ='
  puts "Number of objects: #{@objects.count}"
  @objects.each do |object|
    puts "Processing object ##{object.id}"

    if object.data.nil?
      puts "End processing object ##{object.id}: no data"
    else
      object.data = upgrade_component(object.data.deep_symbolize_keys)
      object.save
      puts "End processing object ##{object.id}"
    end
  end
  puts '====== END UPGRADER ========'
end