Class: YDoc::EmailBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/appcom-ydoc-ruby/email/email_builder.rb

Instance Method Summary collapse

Instance Method Details

#mail_to(to, subject, body, file_or_directory, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/appcom-ydoc-ruby/email/email_builder.rb', line 8

def mail_to(to, subject, body, file_or_directory, options = {})
  is_file = File.file?(file_or_directory) && File.exists?(file_or_directory)
  is_directory = File.directory?(file_or_directory) && File.exists?(file_or_directory)

  options = Map[options]
  options = load_config(options[:config]) || options

  check_options options

  if is_file
    send_file to, subject, body, file_or_directory, options
  elsif is_directory
    Dir["#{file_or_directory}/*.html"].each { |file| send_file to, subject, body, file, options }
  end
end