notifiable-core 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5df3b3bcfd3d08ee0b58a80025ead697fceaac22af37199c400832620644103
4
- data.tar.gz: 824b553df5c6978d4fb9058be35b076623472bc284869f2bbc3f0e8637f62907
3
+ metadata.gz: 98c5713043730258b62c23e08942daba07ec2d600373c65d64494f6fd34d9a01
4
+ data.tar.gz: 33bdabb3ed2d2a8dbf0fb61dbb5eaa0eeb83972f22ba1f3f31b666afbd3739b8
5
5
  SHA512:
6
- metadata.gz: 52e8589031c3919f9f83a8e694c19388771344d59a9e9cf68aefae83772ff08c25a01880e17da5221f0a58a5b76b53187adadae579b81981dc7142e2a8a39690
7
- data.tar.gz: 45108ea49a1965f7e169e47207f8f68daa230d66f0160e7b773afe7688708ee92eb06acd33ba245b8396e3360dd5f0c1a7a59bd316008fcbbb3f101419c5b4ac
6
+ metadata.gz: 8ca200e50537f583ebadb0145431254eb4fa071fa3874371f963a67251661234dbb64ab7c76e75cf36d497b3c29a577803ef1d7395138117fd65082aeaf1e21c
7
+ data.tar.gz: 89d927957447f6de3d02bb0fed70768f589295836785aee0b40d57f382d13a0eff662b7cb7d47a4c5cab042252e93b811d94adad401eec2749adeb7d767bd2cf
@@ -48,13 +48,21 @@ module Notifiable
48
48
  end
49
49
 
50
50
  def delivered!(device_token)
51
+ if notification_statuses.exists?(device_token: device_token)
52
+ s = notification_statuses.find_by(device_token: device_token)
53
+ return if s.delivered?
54
+ s.delivered!
55
+ end
51
56
  increment!(:delivered_count)
52
- notification_statuses.find_by(device_token: device_token).delivered! if notification_statuses.exists?(device_token: device_token)
53
57
  end
54
58
 
55
59
  def opened!(device_token)
60
+ if notification_statuses.exists?(device_token: device_token)
61
+ s = notification_statuses.find_by(device_token: device_token)
62
+ return if s.opened?
63
+ s.opened!
64
+ end
56
65
  increment!(:opened_count)
57
- notification_statuses.find_by(device_token: device_token).opened! if notification_statuses.exists?(device_token: device_token)
58
66
  end
59
67
 
60
68
  private
@@ -27,8 +27,16 @@ module Notifiable
27
27
  update_attributes(status: DELIVERED_STATUS)
28
28
  end
29
29
 
30
+ def delivered?
31
+ status == DELIVERED_STATUS
32
+ end
33
+
30
34
  def opened!
31
35
  update_attributes(status: OPENED_STATUS)
32
36
  end
37
+
38
+ def opened?
39
+ status == OPENED_STATUS
40
+ end
33
41
  end
34
42
  end
@@ -1,3 +1,3 @@
1
1
  module Notifiable
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith