Sha256: d6555ec3626f24f2d409e2ccf278b60086e927622289f3cd79c91b56a929ade2
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Karafka # Namespace for patches of external gems/libraries module Patches # Patch that will allow to use proc based lazy evaluated settings with Dry Configurable # @see https://github.com/dry-rb/dry-configurable/blob/master/lib/dry/configurable.rb module DryConfigurable # We overwrite ::Dry::Configurable::Config to change on proc behaviour # Unfortunately it does not provide an on call proc evaluation, so # this feature had to be added here on demand/ # @param args Any arguments that DryConfigurable::Config accepts def initialize(*args) super @config.each do |key, _value| rebuild(key) end end private # Method that rebuilds a given accessor, so when it consists a proc value, it will # evaluate it upon return # @param method_name [Symbol] name of an accessor that we want to rebuild def rebuild(method_name) define_singleton_method method_name do super().is_a?(Proc) ? super().call : super() end end end end end ::Dry::Configurable::Config.prepend(Karafka::Patches::DryConfigurable)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
karafka-0.5.0.3 | lib/karafka/patches/dry_configurable.rb |
karafka-0.5.0.2 | lib/karafka/patches/dry_configurable.rb |