Class: Mailercity::Message
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(args) ⇒ Message
constructor
A new instance of Message.
- #mailer_name ⇒ Object
Methods included from Helper
Constructor Details
#initialize(args) ⇒ Message
Returns a new instance of Message.
71 72 73 74 |
# File 'lib/mailercity.rb', line 71 def initialize(args) @template = args.fetch(:template) @params = args.fetch(:params) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
69 70 71 |
# File 'lib/mailercity.rb', line 69 def params @params end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
69 70 71 |
# File 'lib/mailercity.rb', line 69 def template @template end |
Instance Method Details
#deliver ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/mailercity.rb', line 80 def deliver log = "[#{self.class.name}] Posting to #{Mailercity.api_base}/#{mailer_name}/#{template}: #{params.to_json}" Mailercity.logger.info(log) unless Mailercity.logger.nil? return true if Mailercity.perform_deliveries == false response = Mailercity.request("/#{mailer_name}/#{template}", params) response.status == 201 end |
#mailer_name ⇒ Object
76 77 78 |
# File 'lib/mailercity.rb', line 76 def mailer_name underscore self.class.name.split(/::/).last end |