module ThousandIsland::Utilities::DeepMerge::TemplateOptions

Public Class Methods

merge_body(*hashes) click to toggle source
# File lib/thousand_island/utilities/utilities.rb, line 54
def self.merge_body(*hashes)
  merge_for_key_and_nested_keys(:body, [], *hashes)
end
merge_header(*hashes) click to toggle source
# File lib/thousand_island/utilities/utilities.rb, line 50
def self.merge_header(*hashes)
  merge_for_key_and_nested_keys(:header, [], *hashes)
end
merge_options(*hashes) click to toggle source

Take a number of hashes used for Template 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.

@param hashes [*Hash] A number of hashes to merge, in the order of precedence

@return [Hash] the merged values

# File lib/thousand_island/utilities/utilities.rb, line 30
def self.merge_options(*hashes)
  hashes.reverse!
  merged = {}
  footer = merge_footer(*hashes)
  header = merge_header(*hashes)
  body = merge_body(*hashes)
  hashes.each do |h|
    merged.merge!(h)
  end
  merged[:footer] = footer
  merged[:header] = header
  merged[:body] = body
  merged
end