Sha256: d0ff86763d566e2e91f66c8e5e4470431867cc2b7fedffdbbfe158b60bc09c5e
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# 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 Dry # Configurable module for Dry-Configurable module Configurable # Config node instance struct class Config # @param args [Array] All arguments that a Struct accepts def initialize(*args) super setup_dynamics end private # Method that sets up all the proc based lazy evaluated dynamic config values def setup_dynamics each_pair do |key, value| next unless value.is_a?(Proc) rebuild(key) end end # 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) metaclass = class << self; self; end metaclass.send(:define_method, method_name) do super().is_a?(Proc) ? super().call : super() end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
karafka-0.5.0.1 | lib/karafka/patches/dry/configurable/config.rb |
karafka-0.5.0 | lib/karafka/patches/dry/configurable/config.rb |