Class: SimpleConf::Loader
- Inherits:
-
Struct
- Object
- Struct
- SimpleConf::Loader
- Defined in:
- lib/simple-conf/loader.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass
6 7 8 |
# File 'lib/simple-conf/loader.rb', line 6 def klass @klass end |
Instance Method Details
#config_file_name ⇒ Object
25 26 27 28 29 |
# File 'lib/simple-conf/loader.rb', line 25 def config_file_name klass.respond_to?(:config_file_name) ? klass.config_file_name : "#{klass.name.downcase.split("::").last}.yml" end |
#path ⇒ Object
21 22 23 |
# File 'lib/simple-conf/loader.rb', line 21 def path "./config/#{config_file_name}" end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/simple-conf/loader.rb', line 7 def run yaml_file.each_pair do |key, value| set(key, value) end yaml_file.fetch(Rails.env, {}).each_pair do |key, value| set(key, value) end if rails_environment_defined? yaml_file.fetch(klass.env, {}).each_pair do |key, value| set(key, value) end if klass.respond_to?(:env) end |
#yaml_file ⇒ Object
31 32 33 34 |
# File 'lib/simple-conf/loader.rb', line 31 def yaml_file content = File.open(path).read YAML.load(ERB.new(content).result) end |