Class: TrafficLightController::Config
- Inherits:
-
Object
- Object
- TrafficLightController::Config
- Defined in:
- lib/traffic_light_controller/config.rb
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to?(method_name) ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
3 4 5 |
# File 'lib/traffic_light_controller/config.rb', line 3 def initialize @config = Hashie::Mash.new(YAML.load_file('./config/config.yml')) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
7 8 9 10 |
# File 'lib/traffic_light_controller/config.rb', line 7 def method_missing(method_name, *args, &block) return config[method_name.to_s] if config.has_key?(method_name.to_s) super end |
Instance Method Details
#respond_to?(method_name) ⇒ Boolean
12 13 14 |
# File 'lib/traffic_light_controller/config.rb', line 12 def respond_to?(method_name) config.has_key?(method_name.to_s) || super end |