Method: DotConfig::Configuration#method_missing

Defined in:
lib/dot_config/configuration.rb

#method_missing(name, *arguments) ⇒ Object

Post treatment of call method which have failed.

Parameters:

  • name (Symbol)

    The name of the method called.

  • arguments (Array)

    The arguments provided with the call.

Returns:

  • (Object)

    The value of the config or call the super method.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/dot_config/configuration.rb', line 60

def method_missing(name, *arguments)
  if name[-1, 1] == '=' && @config.key?(name[0..-2].to_sym)
    if @writing
      @config[name[0..-2].to_sym] = arguments.first
    else
      raise 'The configuration is not allowed in writing'
    end
  elsif @config.key?(name)
    @config[name]
  else
    super
  end
end