Module: RequestHandler::Concerns::ConfigHelper
- Included in:
- Base, BaseParser
- Defined in:
- lib/request_handler/concerns/config_helper.rb
Instance Method Summary collapse
- #deep_to_h(obj) ⇒ Object
- #lookup(config, key) ⇒ Object
- #lookup!(hash, key) ⇒ Object
- #symbolize_key(key) ⇒ Object
Instance Method Details
#deep_to_h(obj) ⇒ Object
18 19 20 21 22 |
# File 'lib/request_handler/concerns/config_helper.rb', line 18 def deep_to_h(obj) obj.to_h.transform_values do |v| v.is_a?(OpenStruct) || v.is_a?(Struct) ? deep_to_h(v) : v end end |
#lookup(config, key) ⇒ Object
10 11 12 |
# File 'lib/request_handler/concerns/config_helper.rb', line 10 def lookup(config, key) config.dig(*symbolize_key(key)) end |
#lookup!(hash, key) ⇒ Object
6 7 8 |
# File 'lib/request_handler/concerns/config_helper.rb', line 6 def lookup!(hash, key) lookup(hash, key) || (raise NoConfigAvailableError, key.to_sym => 'is not configured') end |
#symbolize_key(key) ⇒ Object
14 15 16 |
# File 'lib/request_handler/concerns/config_helper.rb', line 14 def symbolize_key(key) key.split('.').map(&:to_sym) end |