Class: App::Configurator
- Inherits:
-
Object
- Object
- App::Configurator
- Defined in:
- lib/config/app.rb
Overview
Configuratior namespace
Defined Under Namespace
Classes: Struct
Constant Summary collapse
- FILES_EXTENSION =
'yaml'
- DEFAULT_ENVIRONMENT =
'production'
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#files_path ⇒ Object
Returns the value of attribute files_path.
-
#use_secure_yaml ⇒ Object
Returns the value of attribute use_secure_yaml.
Instance Method Summary collapse
- #global_name=(name) ⇒ Object
-
#initialize ⇒ Configurator
constructor
A new instance of Configurator.
-
#load!(name, filter: nil) ⇒ Object
options allowed:.
- #load_all! ⇒ Object
Constructor Details
#initialize ⇒ Configurator
Returns a new instance of Configurator.
59 60 61 62 |
# File 'lib/config/app.rb', line 59 def initialize @environment = DEFAULT_ENVIRONMENT @use_secure_yaml = false end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
55 56 57 |
# File 'lib/config/app.rb', line 55 def environment @environment end |
#files_path ⇒ Object
Returns the value of attribute files_path.
55 56 57 |
# File 'lib/config/app.rb', line 55 def files_path @files_path end |
#use_secure_yaml ⇒ Object
Returns the value of attribute use_secure_yaml.
55 56 57 |
# File 'lib/config/app.rb', line 55 def use_secure_yaml @use_secure_yaml end |
Instance Method Details
#global_name=(name) ⇒ Object
80 81 82 83 |
# File 'lib/config/app.rb', line 80 def global_name=(name) Object.send(:remove_const, name) if Object.const_defined?(name) Object.const_set(name, App.config) end |
#load!(name, filter: nil) ⇒ Object
options allowed:
environment: ‘production’ filter: ‘filter character’
75 76 77 78 |
# File 'lib/config/app.rb', line 75 def load!(name, filter: nil ) filename = config_filename(name) generate_attr_reader(name, load_formatted_data(filename, filter)) end |
#load_all! ⇒ Object
64 65 66 67 68 69 |
# File 'lib/config/app.rb', line 64 def load_all! files = Dir.glob("#{files_path}/*.#{FILES_EXTENSION}") names = files.map { |f| File.basename(f).split(".").first }.uniq names.each { |name| load!(name) } end |