diff options
| author | Weston Ganger <[email protected]> | 2022-10-09 13:50:56 -0700 |
|---|---|---|
| committer | Weston Ganger <[email protected]> | 2022-10-09 13:50:56 -0700 |
| commit | 8694cab86130b9385231a21994b2f13f4c07924e (patch) | |
| tree | c009a6d0c9c8dba710957e9edc711e1f75b51947 /lib/axlsx/workbook/workbook.rb | |
| parent | fd8366970d9cb3f5fb431ba6c40a2a2ac2737615 (diff) | |
| download | caxlsx-8694cab86130b9385231a21994b2f13f4c07924e.tar.gz caxlsx-8694cab86130b9385231a21994b2f13f4c07924e.zip | |
Remove active_support dependency from axlsx_styler
Diffstat (limited to 'lib/axlsx/workbook/workbook.rb')
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index f9e857fc..417e15a3 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -196,7 +196,6 @@ require 'axlsx/workbook/worksheet/selection.rb' # A helper to apply styles that were added using `worksheet.add_style` # @return [Boolean] - require 'active_support/core_ext/hash/deep_merge' ### TODO: keep or replace with local solution def apply_styles return false if !styled_cells @@ -204,7 +203,7 @@ require 'axlsx/workbook/worksheet/selection.rb' current_style = styles.style_index[cell.style] if current_style - new_style = current_style.deep_merge(cell.raw_style) + new_style = Axlsx.hash_deep_merge(current_style, cell.raw_style) else new_style = cell.raw_style end @@ -419,5 +418,18 @@ require 'axlsx/workbook/worksheet/selection.rb' str << '</workbook>' end + private + + # Utility method for performing a deep merge on a Hash + def hash_deep_merge(first_hash, second_hash) + first_hash.merge(second_hash) do |key, this_val, other_val| + if this_val.is_a?(Hash) && other_val.is_a?(Hash) + this_val.deep_merge(other_val, &block) + else + other_val + end + end + end + end end |
