class Crashbreak::StateRestorer

Public Class Methods

new(error_id) click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 3
def initialize(error_id)
  @error_id = error_id
end

Public Instance Methods

restore() click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 7
def restore
  {}.tap do |restorers_hash|
    restorers.each do |restorer|
      restorers_hash[key_name(restorer)] = restorer.new(dumper_data(restorer)).restore
    end
  end
end

Private Instance Methods

dumper_data(restorer) click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 29
def dumper_data(restorer)
  dumper_name = restorer.to_s.gsub('Restorer', 'Dumper')
  dumpers_data[dumper_name].merge('error_id' => @error_id)
end
dumpers_data() click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 17
def dumpers_data
  @dumpers_data ||= Crashbreak::DumpersDataRepository.new(@error_id).dumpers_data
end
key_name(restorer) click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 34
def key_name(restorer)
  restorer.to_s.gsub('Crashbreak::', '').gsub('Restorer', '').underscore.to_sym
end
restorer_class_by_dumper_name(dumper_name) click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 25
def restorer_class_by_dumper_name(dumper_name)
  dumper_name.gsub('Dumper', 'Restorer').constantize
end
restorers() click to toggle source
# File lib/crashbreak/restorers/state_restorer.rb, line 21
def restorers
  dumpers_data.keys.map {|dumper_name| restorer_class_by_dumper_name(dumper_name)}
end