Module: MailControl::Actor

Extended by:
ActiveSupport::Concern
Defined in:
lib/mail-control/actor.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#actor_logged_emails(options = {}) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/mail-control/actor.rb', line 46

def actor_logged_emails(options = {})

  if options.empty?
    logged_emails
  else
    logged_emails.where(options)
  end

end

#mail_control_classObject



42
43
44
# File 'lib/mail-control/actor.rb', line 42

def mail_control_class
  @mailing_klass ||= mailing_klass ? mailing_klass.classify.constantize : ::LoggedEmail
end

#send_email(name, options = {}) ⇒ Object

Publishes the mailing to the receivers

Examples:

publish an mailing with a act_object and act_target

current_user.send_email(:enquiry, :act_object => @enquiry, :act_target => @listing)

Parameters:

  • options (Hash) (defaults to: {})

    The options to publish with.



32
33
34
35
36
37
38
39
40
# File 'lib/mail-control/actor.rb', line 32

def send_email(name, options={})
  options[:send_after]  = Time.now + options[:send_after]  if options[:send_after].kind_of?(Fixnum)
  options[:send_before] = Time.now + options[:send_before] if options[:send_before].kind_of?(Fixnum)

  raise "Expected Time type. Got:" + options[:send_after].class.name   unless options[:send_after].kind_of?(Time)
  raise "Expected Time type. Got:" + options[:send_before].class.name  unless options[:send_before].kind_of?(Time)

  mail_control_class.send_email(name, {:actor => self}.merge(options))
end