Method: FigTree::ConfigStruct#method_missing

Defined in:
lib/fig_tree.rb

#method_missing(method, *args, &block) ⇒ Object

:nodoc:



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/fig_tree.rb', line 184

def method_missing(method, *args, &block)
  config_key = method.to_s.sub(/=$/, '').to_sym

  # Return the list of setting objects with the given name
  if config_key.to_s.end_with?('objects')
    return _setting_object_method(config_key)
  end

  # Define a new setting object with the given name
  if @setting_templates.key?(config_key) && block_given?
    return _new_setting_object_method(config_key, &block)
  end

  setting = @settings[config_key]

  if setting&.removed && !FigTree.keep_removed_configs
    puts "[Config] #{config_key} has been removed: #{setting.removed}"
  end

  if setting&.deprecation
    return _deprecated_config_method(method, *args)
  end

  return super unless setting

  if block_given?
    return _block_config_method(config_key, &block)
  end

  _default_config_method(config_key, *args)
end