ahoy_email 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acb3c3744cff970d75c695f1c79edec32e7dd7a9bea7342576b7fc87be2d3e4a
4
- data.tar.gz: 1cd08f10de1fa686aa09312cdee054694debe9f7835bb97fd9eb35aa9fc09c01
3
+ metadata.gz: 042ad39e2a371bd33d437f9187d691b665ae267c664703656baa3f7c40612fac
4
+ data.tar.gz: bf6e213b94b8002cd53767272cbdd1a2ea16ac24008c47439e9376615cde04db
5
5
  SHA512:
6
- metadata.gz: 3eb7a246d87edfec081d873c8a464c90a682b81acd5d38877c8551770ba911f0c222bf778b03c2abf390fadf5bf48edabe863187627740c673b86718e082a9e4
7
- data.tar.gz: 15c5a59995db66c0d76bfa5273e8a7f4404b11d80078fbf73765fcfb157d8ed3ff744b7bc694e75c8eb8fc2b4afc5494727fa68fb2f60769f91cf2d1f86e7dec
6
+ metadata.gz: f7d589c0b45ac51efaaf7045d4578810c47524ec43a6ea8a82e65c1d975e86aba45abd8e73d0f6c6a0b7d999cd1e352ffae8113df347de81ecda3108982fd4c2
7
+ data.tar.gz: '0598b1f93fde1645f490e8ab4f02032520f707045b651dfb857b02bad78573b26d1b84f9e317a86c2c9e1126e078d43b1f2e0bc93db3e5fee14db60c6afd08e0'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.1
2
+
3
+ - Use observer instead of interceptor
4
+
1
5
  ## 1.0.0
2
6
 
3
7
  - Removed support for Rails < 4.2
data/lib/ahoy_email.rb CHANGED
@@ -8,7 +8,7 @@ require "safely/core"
8
8
  # modules
9
9
  require "ahoy_email/processor"
10
10
  require "ahoy_email/tracker"
11
- require "ahoy_email/interceptor"
11
+ require "ahoy_email/observer"
12
12
  require "ahoy_email/mailer"
13
13
  require "ahoy_email/version"
14
14
  require "ahoy_email/engine" if defined?(Rails)
@@ -58,6 +58,8 @@ module AhoyEmail
58
58
 
59
59
  ahoy_message.sent_at = Time.now
60
60
  ahoy_message.save!
61
+
62
+ ahoy_message
61
63
  end
62
64
 
63
65
  self.subscribers = []
@@ -73,5 +75,6 @@ end
73
75
 
74
76
  ActiveSupport.on_load(:action_mailer) do
75
77
  include AhoyEmail::Mailer
76
- register_interceptor AhoyEmail::Interceptor
78
+ register_observer AhoyEmail::Observer
79
+ Mail::Message.attr_accessor :ahoy_data, :ahoy_message
77
80
  end
@@ -0,0 +1,7 @@
1
+ module AhoyEmail
2
+ class Observer
3
+ def self.delivered_email(message)
4
+ AhoyEmail::Tracker.new(message).perform
5
+ end
6
+ end
7
+ end
@@ -51,7 +51,7 @@ module AhoyEmail
51
51
  end
52
52
  end
53
53
 
54
- mailer.message["Ahoy-Message"] = data.to_json
54
+ mailer.message.ahoy_data = data
55
55
  end
56
56
 
57
57
  def track_open
@@ -7,15 +7,13 @@ module AhoyEmail
7
7
  end
8
8
 
9
9
  def perform
10
- if message.perform_deliveries && (data_header = message["Ahoy-Message"])
11
- Safely.safely do
12
- data = JSON.parse(data_header.to_s).symbolize_keys
13
- data[:message] = message
14
- AhoyEmail.track_method.call(data)
10
+ Safely.safely do
11
+ # perform_deliveries check still needed in observer
12
+ if message.perform_deliveries && message.ahoy_data
13
+ data = message.ahoy_data.merge(message: message)
14
+ message.ahoy_message = AhoyEmail.track_method.call(data)
15
15
  end
16
16
  end
17
- ensure
18
- message["Ahoy-Message"] = nil if message["Ahoy-Message"]
19
17
  end
20
18
  end
21
19
  end
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -179,8 +179,8 @@ files:
179
179
  - config/routes.rb
180
180
  - lib/ahoy_email.rb
181
181
  - lib/ahoy_email/engine.rb
182
- - lib/ahoy_email/interceptor.rb
183
182
  - lib/ahoy_email/mailer.rb
183
+ - lib/ahoy_email/observer.rb
184
184
  - lib/ahoy_email/processor.rb
185
185
  - lib/ahoy_email/tracker.rb
186
186
  - lib/ahoy_email/version.rb
@@ -1,9 +0,0 @@
1
- module AhoyEmail
2
- class Interceptor
3
- class << self
4
- def delivering_email(message)
5
- AhoyEmail::Tracker.new(message).perform
6
- end
7
- end
8
- end
9
- end