Class: TrafficLightController::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/traffic_light_controller/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

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

Returns:

  • (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