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.



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

def initialize
  @environment = DEFAULT_ENVIRONMENT
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



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

def environment
  @environment
end

#files_pathObject

Returns the value of attribute files_path.



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

def files_path
  @files_path
end

Instance Method Details

#global_name=(name) ⇒ Object



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

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’



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

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

#load_all!Object



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

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