Sha256: c7b83cbfc329f52d4efc7c80a3702a28737a7822ec111ebef8db82296199103f

Contents?: true

Size: 979 Bytes

Versions: 13

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

require 'dry-initializer'
require 'pg_export/lib/pg_export/types'

class PgExport
  module Entities
    class Dump
      extend Dry::Initializer[undefined: false]

      option :name,     Types::DumpName
      option :type,     Types::DumpType
      option :database, Types::Strict::String.constrained(filled: true)
      option :file,     Types::DumpFile, default: proc { PgExport::ValueObjects::DumpFile.new }

      def encrypt(cipher_factory:)
        self.file = file.copy(cipher: cipher_factory.encryptor)
        self.type = :encrypted

        self
      end

      def decrypt(cipher_factory:)
        self.file = file.copy(cipher: cipher_factory.decryptor)
        self.type = :plain

        self
      end

      def to_s
        "#{name} (#{file.size_human})"
      end

      def file=(f)
        @file = Types::DumpFile[f]
      end

      protected

      def type=(t)
        @type = Types::DumpType[t]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pg_export-1.0.0.rc5 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-1.0.0.rc4 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-1.0.0.rc3 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-1.0.0.rc2 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-1.0.0.rc1 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.7 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.6 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.5 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.4 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.3 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.2 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.1 lib/pg_export/lib/pg_export/entities/dump.rb
pg_export-0.7.0 lib/pg_export/lib/pg_export/entities/dump.rb