Module: ThousandIsland::Utilities::DeepMerge::TableOptions

Extended by:
ThousandIsland::Utilities::DeepMerge
Defined in:
lib/thousand_island/utilities/utilities.rb

Class Method Summary collapse

Methods included from ThousandIsland::Utilities::DeepMerge

merge_for_key_and_nested_keys

Class Method Details

.merge_options(*hashes) ⇒ Hash

Take a number of hashes used for Table Options and merge them into one, respecting the structure and nesting according to the pdf options hash. Hashes work in order of precedence, the first in the array overrides, the second, etc.

Parameters:

  • hashes (*Hash)

    A number of hashes to merge, in the order of precedence

Returns:

  • (Hash)

    the merged values



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/thousand_island/utilities/utilities.rb', line 70

def self.merge_options(*hashes)
  hashes.reverse!
  merged = {}
  footer_format = merge_for_key_and_nested_keys(:footer_format, [], *hashes)
  header_format = merge_for_key_and_nested_keys(:header_format, [], *hashes)
  cell_style = merge_for_key_and_nested_keys(:cell_style, [], *hashes)
  hashes.each do |h|
    merged.merge!(h)
  end
  merged[:footer_format] = footer_format
  merged[:header_format] = header_format
  merged[:cell_style] = cell_style
  merged
end