Class: VcrWs::Config
Class Method Summary collapse
-
.define_config_keys(*keys) ⇒ Object
Define dynamic getters and setters for all keys in a loop.
Instance Method Summary collapse
-
#configure(options = {}) ⇒ Object
Configure multiple settings at once.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#reset! ⇒ Object
Reset all settings to defaults.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 15 16 17 |
# File 'lib/vcr_ws/config.rb', line 9 def initialize @settings = { file_base_path: "./spec/fixtures/vcr_ws", current_file_path: nil, test_ws_port: 8080, test_ws_address: "0.0.0.0", vcr_enabled: false } end |
Class Method Details
.define_config_keys(*keys) ⇒ Object
Define dynamic getters and setters for all keys in a loop
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vcr_ws/config.rb', line 21 def define_config_keys(*keys) keys.each do |key| define_method(key) do @settings[key] end define_method("#{key}=") do |value| @settings[key] = value end end end |
Instance Method Details
#configure(options = {}) ⇒ Object
Configure multiple settings at once
45 46 47 48 49 |
# File 'lib/vcr_ws/config.rb', line 45 def configure( = {}) .each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end end |
#reset! ⇒ Object
Reset all settings to defaults
35 36 37 38 39 40 41 42 |
# File 'lib/vcr_ws/config.rb', line 35 def reset! @settings = { file_base_path: "./spec/fixtures/vcr_ws", current_file_path: nil, test_ws_port: 8080, test_ws_address: "0.0.0.0" } end |