Class: EasyConfig::ConfigFile
- Inherits:
-
Object
- Object
- EasyConfig::ConfigFile
- Defined in:
- lib/easy_config/config_file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #configuration ⇒ Object
- #create_configuration ⇒ Object
-
#initialize(path) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
Constructor Details
#initialize(path) ⇒ ConfigFile
Returns a new instance of ConfigFile.
4 5 6 7 |
# File 'lib/easy_config/config_file.rb', line 4 def initialize(path) @path = path @name = File.basename(path, '.*').to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/easy_config/config_file.rb', line 2 def name @name end |
Class Method Details
.all ⇒ Object
21 22 23 24 25 |
# File 'lib/easy_config/config_file.rb', line 21 def self.all @all ||= Dir.glob(EasyConfig::PathResolver.config_path).map do |path| EasyConfig::ConfigFile.new path end end |
.reset! ⇒ Object
27 28 29 |
# File 'lib/easy_config/config_file.rb', line 27 def self.reset! @all = nil end |
Instance Method Details
#configuration ⇒ Object
9 10 11 |
# File 'lib/easy_config/config_file.rb', line 9 def configuration @configuration ||= create_configuration end |
#create_configuration ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/easy_config/config_file.rb', line 13 def create_configuration yaml = YAML::load_file(@path) yaml = yaml[EasyConfig::Env.current] if EasyConfig::Env.has_environment?(yaml) EasyConfig::Configuration.new(yaml) end |