Module: Caffeinate::ActionMailer::Extension
- Defined in:
- lib/caffeinate/action_mailer/extension.rb
Overview
Convenience for setting ‘@mailing`, and convenience methods for inferred `caffeinate_unsubscribe_url` and `caffeinate_subscribe_url`.
Class Method Summary collapse
Instance Method Summary collapse
-
#caffeinate_subscribe_url(mailing: nil, **options) ⇒ Object
Assumes ‘@mailing` is set.
-
#caffeinate_unsubscribe_url(mailing: nil, **options) ⇒ Object
Assumes ‘@mailing` is set.
Class Method Details
.included(klass) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/caffeinate/action_mailer/extension.rb', line 8 def self.included(klass) klass.before_action do @mailing = params[:mailing] if params end klass.helper_method :caffeinate_unsubscribe_url, :caffeinate_subscribe_url end |
Instance Method Details
#caffeinate_subscribe_url(mailing: nil, **options) ⇒ Object
Assumes ‘@mailing` is set
23 24 25 26 |
# File 'lib/caffeinate/action_mailer/extension.rb', line 23 def caffeinate_subscribe_url(mailing: nil, **) mailing ||= @mailing Caffeinate::UrlHelpers.caffeinate_subscribe_url(mailing.caffeinate_campaign_subscription, **) end |
#caffeinate_unsubscribe_url(mailing: nil, **options) ⇒ Object
Assumes ‘@mailing` is set
17 18 19 20 |
# File 'lib/caffeinate/action_mailer/extension.rb', line 17 def caffeinate_unsubscribe_url(mailing: nil, **) mailing ||= @mailing Caffeinate::UrlHelpers.caffeinate_unsubscribe_url(mailing.caffeinate_campaign_subscription, **) end |