Skip to content

v0.15.0

Compare
Choose a tag to compare
@dry-bot dry-bot released this 21 Apr 07:30

Changed

  • The finalize! method (as class or instance method, depending on whether you extend or include Dry::Configurable respectively) now accepts a boolean freeze_values: argument, which if true, will recursively freeze all config values in addition to the config itself. (#105 by @ojab)

    class MyConfigurable
      include Dry::Configurable
    
      setting :db, default: "postgre"
    end
    
    my_obj = MyConfigurable.new
    my_obj.finalize!(freeze_values: true)
    my_obj.config.db << "sql" # Will raise FrozenError
  • Dry::Configurable::Config#update will set hashes as values for non-nested settings (#131 by @ojab)

    class MyConfigurable
      extend Dry::Configurable
    
      setting :sslcert, constructor: ->(v) { v&.values_at(:pem, :pass)&.join }
    end
    
    MyConfigurable.config.update(sslcert: {pem: "cert", pass: "qwerty"})
    MyConfigurable.config.sslcert # => "certqwerty"
  • Dry::Configurable::Config#update will accept any values implicitly convertible to hash via #to_hash (#133 by @timriley)

Compare v0.14.0...v0.15.0