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.
- #yaml_data ⇒ Object
Constructor Details
#initialize(path) ⇒ ConfigFile
Returns a new instance of ConfigFile.
6 7 8 9 |
# File 'lib/easy_config/config_file.rb', line 6 def initialize(path) @path = path @name = File.basename(path, '.*').to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/easy_config/config_file.rb', line 4 def name @name end |
Class Method Details
.all ⇒ Object
30 31 32 |
# File 'lib/easy_config/config_file.rb', line 30 def all @all ||= load_all end |
.reset! ⇒ Object
34 35 36 |
# File 'lib/easy_config/config_file.rb', line 34 def reset! @all = nil end |
Instance Method Details
#configuration ⇒ Object
11 12 13 |
# File 'lib/easy_config/config_file.rb', line 11 def configuration @configuration ||= create_configuration end |
#create_configuration ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/easy_config/config_file.rb', line 15 def create_configuration yaml = yaml_data yaml = yaml[EasyConfig::Env.current] if EasyConfig::Env.has_environment?(yaml) EasyConfig::Configuration.new(yaml) end |
#yaml_data ⇒ Object
23 24 25 26 27 |
# File 'lib/easy_config/config_file.rb', line 23 def yaml_data input = File.read(@path) eruby = ERB.new(input) YAML.load(eruby.result) end |