Sha256: 285c30c20f993f19bd673032c1483647ad772ac444ecfb8364b02149c2464120

Contents?: true

Size: 841 Bytes

Versions: 15

Compression:

Stored size: 841 Bytes

Contents

class UserObserver < ActiveRecord::Observer

  def after_create(user)
    return unless gibbon = mailchimp(user)

    gibbon.list_subscribe({:id=>Preference.get_cached(user.system_id, "mailchimp_all_user_list"), :email_address=>user.email, :double_optin=>false})
    Activity.add(user.system_id, "Subscribed '#{user.email}'", 0, "Mailchimp")
  end

  def before_delete(user)
    return unless gibbon = mailchimp(user)
    gibbon.list_unsubscribe({:id=>Preference.get_cached(user.system_id, "mailchimp_all_user_list"), :email_address=>user.email, :delete_member=>true})
    Activity.add(user.system_id, "Deleted '#{user.email}'", 0, "Mailchimp")
  end
  
  def before_save(user)

  end

  def mailchimp(user)
    key = Preference.get_cached(user.system_id, "mailchimp_api_key") 
    return nil unless key
    return Gibbon.new(key)
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kit_cms-2.3.22 app/models/user_observer.rb
kit_cms-2.3.20 app/models/user_observer.rb
kit_cms-2.3.19 app/models/user_observer.rb
kit_cms-2.3.18 app/models/user_observer.rb
kit_cms-2.3.17 app/models/user_observer.rb
kit_cms-2.3.16 app/models/user_observer.rb
kit_cms-2.3.15 app/models/user_observer.rb
kit_cms-2.3.14 app/models/user_observer.rb
kit_cms-2.3.13 app/models/user_observer.rb
kit_cms-2.3.11 app/models/user_observer.rb
kit_cms-2.3.10 app/models/user_observer.rb
kit_cms-2.3.9 app/models/user_observer.rb
kit_cms-2.3.8 app/models/user_observer.rb
kit_cms-2.3.7 app/models/user_observer.rb
kit_cms-2.3.6 app/models/user_observer.rb