Class: App::Configurator

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfigurator

Returns a new instance of Configurator.



59
60
61
# File 'lib/config/app.rb', line 59

def initialize
  @environment = DEFAULT_ENVIRONMENT
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



56
57
58
# File 'lib/config/app.rb', line 56

def environment
  @environment
end

#files_pathObject

Returns the value of attribute files_path.



56
57
58
# File 'lib/config/app.rb', line 56

def files_path
  @files_path
end

Instance Method Details

#global_name=(name) ⇒ Object



79
80
81
82
# File 'lib/config/app.rb', line 79

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’



74
75
76
77
# File 'lib/config/app.rb', line 74

def load!(name, filter: nil )
  filename = config_filename(name)
  generate_attr_reader(name, load_formatted_data(filename, filter))
end

#load_all!Object



63
64
65
66
67
68
# File 'lib/config/app.rb', line 63

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