Class: Proclaim::Subscription

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/proclaim/subscription.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_token(subscription) ⇒ Object



59
60
61
# File 'app/models/proclaim/subscription.rb', line 59

def self.create_token(subscription)
	verifier.generate(subscription.id)
end

.from_token(token) ⇒ Object



50
51
52
53
54
55
56
57
# File 'app/models/proclaim/subscription.rb', line 50

def self.from_token(token)
	begin
		id = verifier.verify(token)
		Subscription.find_by_id(id)
	rescue ActiveSupport::MessageVerifier::InvalidSignature
		nil
	end
end

.verifierObject



46
47
48
# File 'app/models/proclaim/subscription.rb', line 46

def self.verifier
	ActiveSupport::MessageVerifier.new(Rails.application.secrets.secret_key_base)
end

Instance Method Details

#deliver_new_comment_notification_email(comment) ⇒ Object



38
39
40
# File 'app/models/proclaim/subscription.rb', line 38

def deliver_new_comment_notification_email(comment)
	SubscriptionMailer.new_comment_notification_email(self, comment).deliver_later
end

#deliver_new_post_notification_email(post) ⇒ Object



34
35
36
# File 'app/models/proclaim/subscription.rb', line 34

def deliver_new_post_notification_email(post)
	SubscriptionMailer.new_post_notification_email(self, post).deliver_later
end

#deliver_welcome_emailObject



30
31
32
# File 'app/models/proclaim/subscription.rb', line 30

def deliver_welcome_email
	SubscriptionMailer.welcome_email(self).deliver_later
end

#tokenObject



42
43
44
# File 'app/models/proclaim/subscription.rb', line 42

def token
	Subscription.create_token(self)
end