Method: Rdm::ConfigManager#update_using_hash
- Defined in:
- lib/rdm/config_manager.rb
#update_using_hash(hash, scope: nil) ⇒ Object
Update configuration based on given hash
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rdm/config_manager.rb', line 37 def update_using_hash(hash, scope: nil) scope ||= root_scope hash.each do |key, value| if value.is_a?(Hash) # Try using existing scope child_scope = scope.read_attribute(key) if !child_scope || !child_scope.is_a?(Rdm::ConfigScope) child_scope = Rdm::ConfigScope.new end update_using_hash(value, scope: child_scope) scope.write_attribute(key, child_scope) else scope.write_attribute(key, value) end end end |