Class: Nuntius::Subscriber

Inherits:
ApplicationRecord show all
Includes:
Concerns::Yamlify
Defined in:
app/models/nuntius/subscriber.rb

Instance Method Summary collapse

Instance Method Details

#emailObject



30
31
32
33
34
# File 'app/models/nuntius/subscriber.rb', line 30

def email
  return nuntiable.email if nuntiable.respond_to?(:email)

  super
end

#first_nameObject



18
19
20
21
22
# File 'app/models/nuntius/subscriber.rb', line 18

def first_name
  return nuntiable.first_name if nuntiable.respond_to?(:first_name)

  super
end

#last_nameObject



24
25
26
27
28
# File 'app/models/nuntius/subscriber.rb', line 24

def last_name
  return nuntiable.last_name if nuntiable.respond_to?(:last_name)

  super
end


36
37
38
39
40
# File 'app/models/nuntius/subscriber.rb', line 36

def link(campaign, message, tag: true)
  link_text = campaign.["subscriber_url_text"] || I18n.t("subscriber_url_text")
  url = Nuntius::Engine.routes.url_helpers.subscriber_url(self, host: Nuntius.config.host(message), protocol: "https")
  tag ? "<a href=\"#{url}\" data-nuntius-tracking=\"false\">#{link_text}</a>" : url
end

#nameObject



14
15
16
# File 'app/models/nuntius/subscriber.rb', line 14

def name
  [first_name, last_name].compact.join(" ").presence || email
end


42
43
44
# File 'app/models/nuntius/subscriber.rb', line 42

def unsubscribe_link(campaign, message)
  Nuntius::Engine.routes.url_helpers.unsubscribe_subscriber_url(self, host: Nuntius.config.host(message), protocol: "https")
end