Class: EasyConf::AppConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_conf/app_config.rb

Overview

:nodoc

Constant Summary collapse

MESSAGES =
{
  unpermitted_key:  'Found unpermitted key'.freeze,
  file_not_found:   'Configuration file not found'.freeze,
  config_not_found: 'Configuration not found'.freeze,
}
EXCEPTIONS =
{
  unpermitted_key:  'UnpermittedConfigError'.freeze,
  file_not_found:   'ConfigFileNotFoundError'.freeze,
  config_not_found: 'ConfigNotFoundError'.freeze,
}

Instance Method Summary collapse

Constructor Details

#initializeAppConfig

Returns a new instance of AppConfig.



16
17
18
# File 'lib/easy_conf/app_config.rb', line 16

def initialize
  @table = __read_config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



20
21
22
23
24
# File 'lib/easy_conf/app_config.rb', line 20

def method_missing(meth, *args, &block)
  return __notify(:unpermitted_key, meth) if __list_check(meth)

  __read_from_table(meth) || __read_from_env(meth) || __notify(:config_not_found, meth)
end

Instance Method Details

#__keysObject



26
27
28
# File 'lib/easy_conf/app_config.rb', line 26

def __keys
  @table.keys
end

#__to_hashObject



30
31
32
# File 'lib/easy_conf/app_config.rb', line 30

def __to_hash
  @table.dup
end