Module: HtmlEmailCreator::Helper

Defined in:
lib/html_email_creator/helper.rb

Class Method Summary collapse

Class Method Details

.find_recursively(start_from_dir, dir_or_file, default_if_not_found = nil) ⇒ Object

Find recursively starting from start_from_dir and continues towards a root.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/html_email_creator/helper.rb', line 8

def find_recursively(start_from_dir, dir_or_file, default_if_not_found = nil)
  current_file = File.join(start_from_dir, dir_or_file)
  if File.exists?(current_file)
    current_file
  else
    next_file = File.dirname(start_from_dir)
    if start_from_dir == next_file
      return default_if_not_found
    end
  
    # continue searching
    find_recursively(next_file, dir_or_file, default_if_not_found)
  end
end