Class: Mail::Postmark
- Inherits:
-
Object
- Object
- Mail::Postmark
- Defined in:
- lib/postmark/handlers/mail.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #api_client ⇒ Object
- #deliver!(mail) ⇒ Object
-
#initialize(values) ⇒ Postmark
constructor
A new instance of Postmark.
Constructor Details
#initialize(values) ⇒ Postmark
Returns a new instance of Postmark.
6 7 8 |
# File 'lib/postmark/handlers/mail.rb', line 6 def initialize(values) self.settings = { :api_token => ENV['POSTMARK_API_TOKEN'] }.merge(values) end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
4 5 6 |
# File 'lib/postmark/handlers/mail.rb', line 4 def settings @settings end |
Instance Method Details
#api_client ⇒ Object
24 25 26 27 28 |
# File 'lib/postmark/handlers/mail.rb', line 24 def api_client settings = self.settings.dup api_token = settings.delete(:api_token) || settings.delete(:api_key) ::Postmark::ApiClient.new(api_token, settings) end |
#deliver!(mail) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/postmark/handlers/mail.rb', line 10 def deliver!(mail) response = if mail.templated? api_client.(mail) else api_client.(mail) end if settings[:return_response] response else self end end |