Sha256: 92065f85243897711489a3df1d294a1326c566c0c103b589ba150e66341d5213

Contents?: true

Size: 772 Bytes

Versions: 13

Compression:

Stored size: 772 Bytes

Contents

module MailForm
  class Notifier < ActionMailer::Base
    self.mailer_name = "mail_form"
    append_view_path File.expand_path('../views', __FILE__)

    def contact(resource)
      if resource.request.nil? && resource.class.mail_appendable.any?
        raise ScriptError, "You set :append values but forgot to give me the request object"
      end

      @resource = @form = resource

      resource.class.mail_attachments.each do |attribute|
        value = resource.send(attribute)
        next unless value.respond_to?(:read)
        attachments[value.original_filename] = value.read
      end

      headers = resource.headers
      headers[:from]    ||= resource.email
      headers[:subject] ||= resource.class.model_name.human
      mail(headers)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mail_form-1.9.0 lib/mail_form/notifier.rb
mail_form-1.8.1 lib/mail_form/notifier.rb
mail_form-1.8.0 lib/mail_form/notifier.rb
mail_form-1.7.1 lib/mail_form/notifier.rb
mail_form-1.7.0 lib/mail_form/notifier.rb
mail_form-1.6.0 lib/mail_form/notifier.rb
mail_form-1.5.1 lib/mail_form/notifier.rb
mail_form-1.5.0 lib/mail_form/notifier.rb
mail_form-1.5.0.rc lib/mail_form/notifier.rb
mail_form-1.4.1 lib/mail_form/notifier.rb
mail_form-1.4.0 lib/mail_form/notifier.rb
mail_form-1.3.0 lib/mail_form/notifier.rb
mail_form-1.2.1 lib/mail_form/notifier.rb