Module: Confo::SubconfigsManager::ClassMethods
- Defined in:
- lib/confo/concerns/subconfigs_manager.rb
Instance Method Summary collapse
- #define_subconfig_reader(subconfig_name, subconfig_options) ⇒ Object
- #includes_config(arg, options = {}) ⇒ Object
- #subconfigs_options ⇒ Object
Instance Method Details
#define_subconfig_reader(subconfig_name, subconfig_options) ⇒ Object
37 38 39 40 41 |
# File 'lib/confo/concerns/subconfigs_manager.rb', line 37 def define_subconfig_reader(subconfig_name, ) define_method(subconfig_name) do | = nil, overrides = nil, &block| subconfig_internal(subconfig_name, , overrides, &block) end end |
#includes_config(arg, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/confo/concerns/subconfigs_manager.rb', line 6 def includes_config(arg, = {}) @subconfigs_options ||= {} # Support different syntaxes: # includes_config :actions # includes_config of: :actions # includes_config for: :actions name = (arg.kind_of?(Hash) ? arg[:of] || arg[:for] : arg).to_sym = @subconfigs_options[name] ||= { name: name, fallback_class_name: 'Confo::Config' } .merge!() @subconfigs_options[name] = define_subconfig_reader(name, ) self end |
#subconfigs_options ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/confo/concerns/subconfigs_manager.rb', line 24 def = @subconfigs_options ? @subconfigs_options.dup : {} if superclass.respond_to?(:subconfigs_options) superclass..each do |name, | = {} .merge!([name]) if [name] .merge!() [name] = end end end |