Class: OpenMeteo::Configuration
- Inherits:
-
Object
- Object
- OpenMeteo::Configuration
- Defined in:
- lib/open_meteo/configuration.rb
Overview
The global configuration of the OpenMeteo client.
Class Method Summary collapse
-
.add_setting(name, default) ⇒ Object
Create a getter and a setter for a setting.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 |
# File 'lib/open_meteo/configuration.rb', line 7 def initialize @config = {} end |
Class Method Details
.add_setting(name, default) ⇒ Object
Create a getter and a setter for a setting.
If the default value is a Proc, it will be called on initialize.
18 19 20 21 22 23 24 25 26 |
# File 'lib/open_meteo/configuration.rb', line 18 def self.add_setting(name, default) define_method name do @config[name] ||= default.is_a?(Proc) ? default.call : default end define_method "#{name}=" do |value| @config[name] = value end end |