Class: MailHandler::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/mailhandler/sender.rb

Overview

Class for sending email, and storing details about the sending.

Direct Known Subclasses

MailHandler::Sending::PostmarkAPISender

Defined Under Namespace

Classes: Sending

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher) ⇒ Sender

Returns a new instance of Sender.

Parameters:

  • dispatcher (Sending::Oblect)
    • sender type used for sending email



23
24
25
26
27
# File 'lib/mailhandler/sender.rb', line 23

def initialize(dispatcher)
  @dispatcher = dispatcher
  @sending = Sending.new
  @validate_response = false
end

Instance Attribute Details

#dispatcherObject

Returns the value of attribute dispatcher.



11
12
13
# File 'lib/mailhandler/sender.rb', line 11

def dispatcher
  @dispatcher
end

#sendingObject

Returns the value of attribute sending.



11
12
13
# File 'lib/mailhandler/sender.rb', line 11

def sending
  @sending
end

#validate_responseObject

Returns the value of attribute validate_response.



11
12
13
# File 'lib/mailhandler/sender.rb', line 11

def validate_response
  @validate_response
end

Instance Method Details

#dispatcher_clientObject



37
38
39
# File 'lib/mailhandler/sender.rb', line 37

def dispatcher_client
  dispatcher.client if dispatcher.respond_to?(:client)
end

#send_email(email) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/mailhandler/sender.rb', line 29

def send_email(email)
  init_sending_details(email)
  response = dispatcher.send(email)
  update_sending_details(response)
  check_response(response)
  response
end