Class: Hackademy::Config
- Inherits:
-
Object
- Object
- Hackademy::Config
- Defined in:
- lib/hackademy/hackademy.rb
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #method_missing(method) ⇒ Object
- #set_config_variable(name, value) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hackademy/hackademy.rb', line 22 def initialize if File.exists?("Resources/Config.yml") raw_config = File.read("Resources/Config.yml") erb_config = ERB.new(raw_config).result settings = YAML.load(erb_config)["hackademic"] if settings settings.each { |name, value| set_config_variable(name, value) } end end def method_missing(method) "" end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
34 35 36 |
# File 'lib/hackademy/hackademy.rb', line 34 def method_missing(method) "" end |
Instance Method Details
#set_config_variable(name, value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hackademy/hackademy.rb', line 11 def set_config_variable(name, value) if value.is_a? Hash value.each do |key, value| set_config_variable("#{name}_#{key}", value) end end # puts "=== Setting #{name} to #{value}" instance_variable_set("@#{name}", ENV[name.upcase] || value) self.class.class_eval { attr_reader name.intern } end |