acts_as_readable 2.5.0 → 2.5.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: 8ebb4f311aa3f11a92b82cc87aa496a4501202dc5e63a22f619bb1e01195c758
4
- data.tar.gz: 21bd9b62364d989f6103c4b112d989d6234274c7f3a0faa05d2eaeac1a3a8de2
3
+ metadata.gz: 30458b57470ac5d7b6bb60a763f96b982c00eb79cddf118dac4cb1a8c3ce987b
4
+ data.tar.gz: 23a3911dd0b46152113dbacea0fe6ae40aedbea3be5a8ed045b749f8094b15b9
5
5
  SHA512:
6
- metadata.gz: 3190c64def5ec6c0ad43f22a2963a58132db21c7a4fb57302f18069e3f4d1a3757c581f1a6f256b882ab4e3a3e84c10f5dab1e492d93756342fbbadd8517ad63
7
- data.tar.gz: 4c5ebf476c915aedf33852450ffc05d48ebb2a3d420f2bcdd0e41d487eeabf1feb784caaf2a6a37d4abc5a420f487508064da53574af2aea8da1f5c975baf015
6
+ metadata.gz: 67cc32a787dac99c949d85d4f1159aefe2a04abd3511c65ccf7a14b0f357d44e789163893123496408a5f42fa9af83314aa5ae1fe2b78bb520809b007c2cf51d
7
+ data.tar.gz: 40a91e90aec4320f150a81c0cb8b5aa533e594e8dee429dd4d37854dec8af4059e7bb8b48da72fe04cc72b23830f0014b70ab989f341180c70104e8d08bc40cb
@@ -107,15 +107,24 @@ module ActsAsReadable
107
107
  reading.updated_at = Time.now # Explicitly set the read time to now in order to force a save in case we haven't changed anything else about the reading
108
108
  reading.state = :read
109
109
  reading.save!
110
+ @read_by_retried = false
110
111
  rescue ActiveRecord::RecordNotUnique
111
- # Database-level uniqueness constraint failed.
112
- return self
112
+ unless @read_by_retried
113
+ @read_by_retried = true
114
+ retry
115
+ end
113
116
  end
114
117
 
115
118
  def unread_by!(user)
116
119
  reading = Reading.find_or_initialize_by(:user_id => user.id, :readable_id => self.id, :readable_type => HelperMethods.readable_type(self.class))
117
120
  reading.state = :unread
118
121
  reading.save!
122
+ @unread_by_retried = false
123
+ rescue ActiveRecord::RecordNotUnique
124
+ unless @unread_by_retried
125
+ @unread_by_retried = true
126
+ retry
127
+ end
119
128
  end
120
129
 
121
130
  def read_by?(user)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_readable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen