notifiable-core 0.1.4 → 0.1.5

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: c0865eabff60a2f39d986369dfa5b7fb781d8504aca696a933c2ce7928a86751
4
- data.tar.gz: 817efa58bc322fa260647ff998f0af1095582a50bb0dcf6d804af9a0b2c419ce
3
+ metadata.gz: ee5fccd800a04500a363939b090a2a9f88faa45c84a6d43af689e0036efe1191
4
+ data.tar.gz: a7bf3297962dda646bc268d9ee07a09008f89a917e0450f4c896e85ed57c6ad2
5
5
  SHA512:
6
- metadata.gz: 715b4ecbc1da59868a6b02e8471400b14abc8f705d9e13c03cd0ee2c5910482caa0a7fe329c8920473bc9a2578e0bd859cb95ca999bc03180f67901ba2d7e317
7
- data.tar.gz: 5d92f645691f0a6822990e8812ecae30320c62f2f0da08657a8f5b0d0a6f93531f0c9be65eb545d2283fec890289f81fec3e8e639b9bff044bc081b23276803f
6
+ metadata.gz: f3816a57d151d68f66dce06cdf8210a773a03e965b08cb91955a6baa788ce8c04d3c7d9e5b0ba0f1495814986cf9deeee91a9a85a27f25c78691cf1bbdcbabee
7
+ data.tar.gz: 119f7f22adc594d0af15b16b5f7c2811cf256184138623c0f788573690eb8a8600f0b18f8aae952f082068116ee84d1d03d49c481d1ae09b2a2c853e5ab593bf
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddStatusToNotifications < ActiveRecord::Migration[4.2]
4
+ def change
5
+ add_column :notifiable_notifications, :status, :integer, default: 0
6
+ end
7
+ end
@@ -10,12 +10,20 @@ module Notifiable
10
10
  serialize :parameters
11
11
 
12
12
  has_many :notification_statuses, class_name: 'Notifiable::NotificationStatus', dependent: :destroy
13
+
14
+ after_initialize :set_default_status
15
+
16
+ ERROR_STATUS = -1
17
+ WAITING_STATUS = 0
18
+ SENDING_STATUS = 1
19
+ FINISHED_STATUS = 2
13
20
 
14
21
  def batch
22
+ update(status: SENDING_STATUS)
15
23
  yield(self)
16
- update(last_error_message: nil)
24
+ update_attributes({status: FINISHED_STATUS, last_error_message: nil})
17
25
  rescue => e
18
- update(last_error_message: e.message)
26
+ update_attributes({status: ERROR_STATUS, last_error_message: e.message})
19
27
  raise e
20
28
  ensure
21
29
  close
@@ -41,6 +49,10 @@ module Notifiable
41
49
 
42
50
  private
43
51
 
52
+ def set_default_status
53
+ self.status ||= WAITING_STATUS
54
+ end
55
+
44
56
  def notifiers
45
57
  @notifiers ||= {}
46
58
  end
@@ -1,3 +1,3 @@
1
1
  module Notifiable
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-26 00:00:00.000000000 Z
11
+ date: 2018-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -201,6 +201,7 @@ files:
201
201
  - db/migrate/201806182135000_add_thread_id_to_notifications.rb
202
202
  - db/migrate/201806242135000_add_category_to_notifications.rb
203
203
  - db/migrate/201808242135000_add_error_message_to_notification_statuses.rb
204
+ - db/migrate/201808272135000_add_status_to_notifications.rb
204
205
  - lib/notifiable.rb
205
206
  - lib/notifiable/app.rb
206
207
  - lib/notifiable/device_token.rb