Class: RubyPitaya::ConfigSpecHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/core/spec-helpers/config_spec_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_config = {}) ⇒ ConfigSpecHelper

Returns a new instance of ConfigSpecHelper.



5
6
7
8
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 5

def initialize(default_config = {})
  @config_mock = {}
  @default_config = default_config
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
13
14
15
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 10

def [](key)
  result = @config_mock[key]
  return result unless result.nil?

  return @default_config[key]
end

#add(key, value) ⇒ Object



27
28
29
30
31
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 27

def add(key, value)
  keys = key.split('.')
  add_hash = undig(*keys, value)
  @config_mock = merge_recursively(@config_mock, add_hash).deep_symbolize_keys.stringify_keys
end

#auto_reloadObject



17
18
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 17

def auto_reload
end

#clearObject



33
34
35
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 33

def clear
  @config_mock = {}
end

#config_core_override=(value) ⇒ Object



24
25
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 24

def config_core_override=(value)
end

#config_mock=(value) ⇒ Object



20
21
22
# File 'lib/rubypitaya/core/spec-helpers/config_spec_helper.rb', line 20

def config_mock=(value)
  @config_mock = value.deep_symbolize_keys.stringify_keys
end