Class: Proclaim::Subscription
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Proclaim::Subscription
- Defined in:
- app/models/proclaim/subscription.rb
Class Method Summary collapse
Instance Method Summary collapse
- #deliver_new_comment_notification_email(comment) ⇒ Object
- #deliver_new_post_notification_email(post) ⇒ Object
- #deliver_welcome_email ⇒ Object
- #token ⇒ Object
Class Method Details
.create_token(subscription) ⇒ Object
67 68 69 |
# File 'app/models/proclaim/subscription.rb', line 67 def self.create_token(subscription) verifier.generate(subscription.id) end |
.from_token(token) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/models/proclaim/subscription.rb', line 58 def self.from_token(token) begin id = verifier.verify(token) Subscription.find(id) rescue ActiveSupport::MessageVerifier::InvalidSignature raise ActiveRecord::RecordNotFound end end |
.verifier ⇒ Object
54 55 56 |
# File 'app/models/proclaim/subscription.rb', line 54 def self.verifier ActiveSupport::MessageVerifier.new(Proclaim.secret_key) end |
Instance Method Details
#deliver_new_comment_notification_email(comment) ⇒ Object
46 47 48 |
# File 'app/models/proclaim/subscription.rb', line 46 def deliver_new_comment_notification_email(comment) SubscriptionMailer.with(subscription_id: id, comment_id: comment.id).new_comment_notification_email.deliver_later end |
#deliver_new_post_notification_email(post) ⇒ Object
42 43 44 |
# File 'app/models/proclaim/subscription.rb', line 42 def deliver_new_post_notification_email(post) SubscriptionMailer.with(subscription_id: id, post_id: post.id).new_post_notification_email.deliver_later end |
#deliver_welcome_email ⇒ Object
38 39 40 |
# File 'app/models/proclaim/subscription.rb', line 38 def deliver_welcome_email SubscriptionMailer.with(subscription_id: id).welcome_email.deliver_later end |
#token ⇒ Object
50 51 52 |
# File 'app/models/proclaim/subscription.rb', line 50 def token Subscription.create_token(self) end |