Sha256: b46c2fc06ecf7de57900130eb598a0e9ceea40ea71703928099ac2bfb7466ad7
Contents?: true
Size: 646 Bytes
Versions: 2
Compression:
Stored size: 646 Bytes
Contents
# frozen_string_literal: true class Cryptoform::Config::Builder Config = Data.define(:port, :states) def initialize @port = 3000 @states = {} end def port(port) @port = port end def state(name, &) name = name.to_sym raise ArgumentError, "state #{name} already configured" if @states.key?(name) @states[name] = Cryptoform::Config::StateConfigBuilder.new(name, &) end def validate! @states.each_value(&:validate!) raise Cryptoform::ConfigValidationError, "port must be an integer" if @key.is_a?(Numeric) end def config Config.new(@port, @states.transform_values(&:config)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cryptoform-0.4.0 | lib/cryptoform/config/builder.rb |
cryptoform-0.2.0 | lib/cryptoform/config/builder.rb |