Sha256: c7345779985dd7c92be1af26a3126f6e14d526da2915da63844dbf803fde949b

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

require 'pg_export/lib/pg_export/value_objects/result'

class PgExport
  module Operations
    class RemoveOldDumps
      def initialize(gateway_dump_repository:, keep:)
        @gateway_dump_repository, @keep = gateway_dump_repository, keep
      end

      def name
        :remove_old_dumps
      end

      def call(dump:, gateway:)
        dumps = gateway_dump_repository.by_database_name(
          database_name: dump.database,
          gateway: gateway,
          offset: keep
        )
        dumps.each do |d|
          gateway.delete(d.name)
        end

        ValueObjects::Success.new(removed_dumps: dumps, gateway: gateway)
      end

      private

      attr_reader :gateway_dump_repository, :keep
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_export-1.0.0.rc6 lib/pg_export/lib/pg_export/operations/remove_old_dumps.rb