Module: ThousandIsland::Utilities::DeepMerge::TemplateOptions

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_body(*hashes) ⇒ Object



54
55
56
# File 'lib/thousand_island/utilities/utilities.rb', line 54

def self.merge_body(*hashes)
  merge_for_key_and_nested_keys(:body, [], *hashes)
end


45
46
47
48
# File 'lib/thousand_island/utilities/utilities.rb', line 45

def self.merge_footer(*hashes)
  keys = [:numbering_options, :style]
  merge_for_key_and_nested_keys(:footer, keys, *hashes)
end

.merge_header(*hashes) ⇒ Object



50
51
52
# 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) ⇒ Hash

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.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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