Class: MailchimpNotificationHandler
- Inherits:
-
Object
- Object
- MailchimpNotificationHandler
- Defined in:
- lib/mcmailer/mailchimp_notification_handler.rb
Constant Summary collapse
- NO_OP_LAMBDA =
lambda {|data| nil}
Instance Method Summary collapse
-
#initialize(params, logger, logic, bool_cols = []) ⇒ MailchimpNotificationHandler
constructor
A new instance of MailchimpNotificationHandler.
- #process ⇒ Object
Constructor Details
#initialize(params, logger, logic, bool_cols = []) ⇒ MailchimpNotificationHandler
Returns a new instance of MailchimpNotificationHandler.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mcmailer/mailchimp_notification_handler.rb', line 4 def initialize(params, logger, logic, bool_cols=[]) @params = params @logger = logger @bool_columns = bool_cols @logic = logic @logic.default = NO_OP_LAMBDA # These attrs get populated when the @params hash is parsed. @notification_type = '' @data = {} @message = '' end |
Instance Method Details
#process ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mcmailer/mailchimp_notification_handler.rb', line 17 def process if valid_notification? parse_params @logger.info("[Mailchimp (#{@params['fired_at']})] #{@message}") @logic[@notification_type].call(@data) else @logger.error("[Mailchimp] Invalid notification (possible reasons: forged notification from somebody besides Mailchimp, incorrect secret code, invalid notification from Mailchimp, or invalid handling of notification.)\nparams => #{@params}") end end |