Sha256: f13e7fe2e40cf0de8e8b2ae261f2c2cda03dc9f1d9d305d6e5487b271273122b

Contents?: true

Size: 583 Bytes

Versions: 5

Compression:

Stored size: 583 Bytes

Contents

module Workarea
  module MailChimp
    class SubscriptionEdit
      include Sidekiq::Worker
      include Sidekiq::CallbacksWorker

      sidekiq_options(
        enqueue_on: {
          User => [:save],
          ignore_if: -> { !SubscriptionEdit.should_enqueue?(id) }
        },
        queue: "low",
        retry: true
      )

      def self.should_enqueue?(id)
        user = User.find(id)
        user.email_signup
      end

      def perform(id)
        user = User.find(id)

        Workarea::MailChimp.gateway.subscribe(user.email, user: user)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-mail_chimp-3.1.0 app/workers/workarea/mail_chimp/subscription_edit.rb
workarea-mail_chimp-3.0.5 app/workers/workarea/mail_chimp/subscription_edit.rb
workarea-mail_chimp-3.0.4 app/workers/workarea/mail_chimp/subscription_edit.rb
workarea-mail_chimp-3.0.3 app/workers/workarea/mail_chimp/subscription_edit.rb
workarea-mail_chimp-3.0.2 app/workers/workarea/mail_chimp/subscription_edit.rb