File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ def facts
9898
9999 def add_facts ( new_facts = { } )
100100 validate_fact_names ( new_facts )
101- @facts = Bolt ::Util . deep_merge ( @facts , new_facts )
101+ Bolt ::Util . deep_merge! ( @facts , new_facts )
102102 end
103103
104104 def features
Original file line number Diff line number Diff line change @@ -212,6 +212,17 @@ def deep_merge(hash1, hash2)
212212 hash1 . merge ( hash2 , &recursive_merge )
213213 end
214214
215+ def deep_merge! ( hash1 , hash2 )
216+ recursive_merge = proc do |_key , h1 , h2 |
217+ if h1 . is_a? ( Hash ) && h2 . is_a? ( Hash )
218+ h1 . merge! ( h2 , &recursive_merge )
219+ else
220+ h2
221+ end
222+ end
223+ hash1 . merge! ( hash2 , &recursive_merge )
224+ end
225+
215226 # Accepts a Data object and returns a copy with all hash keys
216227 # modified by block. use &:to_s to stringify keys or &:to_sym to symbolize them
217228 def walk_keys ( data , &block )
You can’t perform that action at this time.
0 commit comments