Sha256: 0a094cca6297dc3757cc0085208a52e0e0b261c360228584e73658086bf9bc0d

Contents?: true

Size: 544 Bytes

Versions: 2

Compression:

Stored size: 544 Bytes

Contents

module StatusPageVi
  class BackupService < BaseService
    def self.backup(path, resource)
      resources(resource).each do |resource_class|
        FileUtils.cp(
          resource_class.cache_file_path,
          "#{path}/#{resource_class.name.split("::").last}.json"
        )
      end
    end

    def self.restore(path_to_file)
      validator = StatusPageVi::BackupFileValidator.new(path_to_file)

      raise InvalidBackup unless validator.valid_backup?

      validator.resource.update_storage(validator.json_data)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
status_page_vi-0.3.1 lib/status_page_vi/services/backup_service.rb
status_page_vi-0.3.0 lib/status_page_vi/services/backup_service.rb