Module: Eco::API::Common::Loaders::Config::Block::ClassMethods
- Defined in:
- lib/eco/api/common/loaders/config/block.rb
Instance Method Summary collapse
-
#config_apply!(*key, on: self, all: false) ⇒ Object
Applies the configuration to the target
on. -
#config_block(section = nil, *keys, &block) ⇒ Object
To create samples of configurations.
- #config_copy(*key, to:, all: false) ⇒ Object
Instance Method Details
#config_apply!(*key, on: self, all: false) ⇒ Object
Applies the configuration to the target on.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/eco/api/common/loaders/config/block.rb', line 32 def config_apply!(*key, on: self, all: false) # rubocop:disable Naming/MethodParameterName if all @config_block ||= {} @config_block.each_key do |k| config_apply!(*k, on: on) end else on.instance_exec(&config_block(*key)) end self rescue LocalJumpError => err puts "Missing config block for key '#{key}': #{err}" raise end |
#config_block(section = nil, *keys, &block) ⇒ Object
To create samples of configurations
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/eco/api/common/loaders/config/block.rb', line 16 def config_block(section = nil, *keys, &block) section ||= :general key = [section, *keys] @config_block ||= {} return @config_block[key] unless block_given? unless @config_block[key].nil? msg = "Reconfiguring config_block (#{key}) on #{self}" session.log(:warn) { msg } end @config_block[key] = block end |
#config_copy(*key, to:, all: false) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/eco/api/common/loaders/config/block.rb', line 49 def config_copy(*key, to:, all: false) @config_block ||= {} if all @config_block.dup.each do |keys, block| to.config_block(*keys, &block) end else to.config_block(*key, &config_block(*key)) end self end |