Sha256: d609d1e68d507feac8c801f0c232c0e4f12eff463196d76d49987f894320c11b
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true class Cryptoform::Config::StateConfigBuilder Config = Data.define(:storage_backend, :encryption_backend) STORAGE_BACKENDS = { file: Cryptoform::StorageBackends::File }.freeze ENCRYPTION_BACKENDS = { lockbox: Cryptoform::EncryptionBackends::Lockbox }.freeze def initialize(name, &) @name = name instance_exec(&) end def storage_backend(name, **params) name = name.to_sym raise ArgumentError, "unknown storage backend #{name}" unless STORAGE_BACKENDS.key?(name) @storage_backend = STORAGE_BACKENDS[name].new(@name, **params) end def encryption_backend(name, **params) name = name.to_sym raise ArgumentError, "unknown encryption backend #{name}" unless ENCRYPTION_BACKENDS.key?(name) @encryption_backend = ENCRYPTION_BACKENDS[name].new(@name, **params) end def config Config.new(@storage_backend, @encryption_backend) end def validate! if @storage_backend.nil? raise Cryptoform::ConfigValidationError, "storage backend must be specified for state '#{@name}'" end return unless @encryption_backend.nil? raise Cryptoform::ConfigValidationError, "encryption backend must be specified for state '#{@name}'" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cryptoform-0.4.0 | lib/cryptoform/config/state_config_builder.rb |
cryptoform-0.2.0 | lib/cryptoform/config/state_config_builder.rb |