Class: Gemgento::Subscriber

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gemgento/subscriber.rb

Overview

Author:

  • Gemgento LLC

Class Method Summary collapse

Class Method Details

.add_user(user) ⇒ Object



19
20
21
22
23
24
# File 'app/models/gemgento/subscriber.rb', line 19

def self.add_user(user)
  subscriber = Subscriber.find_or_initialize_by(email: user.email)
  subscriber.first_name = user.first_name
  subscriber.last_name = user.last_name
  subscriber.save
end

.manage(user, subscribe) ⇒ Object



11
12
13
14
15
16
17
# File 'app/models/gemgento/subscriber.rb', line 11

def self.manage(user, subscribe)
  if subscribe
    add_user user
  else
    remove_user user
  end
end

.remove_user(user) ⇒ Object



26
27
28
# File 'app/models/gemgento/subscriber.rb', line 26

def self.remove_user(user)
  Subscriber.where(email: user.email).destroy_all
end