Sha256: b205712111ab5a2cc464a9186521c279cd02871a99bcf85ff2cca6b25e3b130e

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

module CatarseMonkeymail::ProjectConcern
  extend ActiveSupport::Concern

  included do
    def mailchimp
      @mailchimp ||= ::CatarseMonkeymail::MailchimpApi.start
    end

    def subscribe_owner_to_success_list
      subscribe_to_list ::CatarseSettings[:mailchimp_successful_projects_list]
    end

    def subscribe_owner_to_failed_list
      subscribe_to_list ::CatarseSettings[:mailchimp_failed_projects_list]
    end

    private

    def subscribe_to_list list_id
      mailchimp.lists.subscribe list_id, { email: self.user.email }, subscriber_args
    end

    def subscriber_args
      {
        fname: self.user.name,
        city: self.user.address_city,
        state: self.user.address_state
      }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
catarse_monkeymail-0.1.0 app/models/catarse_monkeymail/project_concern.rb