Class: Mailkick::Processor
- Inherits:
-
Object
- Object
- Mailkick::Processor
- Defined in:
- lib/mailkick/processor.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message) ⇒ Processor
constructor
A new instance of Processor.
- #process ⇒ Object
Constructor Details
#initialize(message) ⇒ Processor
Returns a new instance of Processor.
5 6 7 |
# File 'lib/mailkick/processor.rb', line 5 def initialize() = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/mailkick/processor.rb', line 3 def end |
Instance Method Details
#process ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mailkick/processor.rb', line 9 def process email = .to.first user = Mailkick.user_method.call(email) if Mailkick.user_method list = [:mailkick_list].try(:value) if list # remove header [:mailkick_list] = nil end verifier = ActiveSupport::MessageVerifier.new(Mailkick.secret_token) token = verifier.generate([email, user.try(:id), user.try(:class).try(:name), list]) parts = .parts.any? ? .parts : [] parts.each do |part| if part.content_type.match(/text\/(html|plain)/) part.body = part.body.decoded.gsub(/%7B%7BMAILKICK_TOKEN%7D%7D/, CGI.escape(token)) end end end |