notification-settings 1.0.0.beta10 → 1.0.0.beta11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/notification_settings/setting.rb +13 -0
- data/app/models/notification_settings/subscription.rb +13 -0
- data/lib/notification_settings/engine.rb +1 -0
- data/lib/notification_settings/notification_library.rb +3 -0
- data/lib/notification_settings/notification_scopes.rb +3 -0
- data/lib/notification_settings/setting_library.rb +2 -0
- data/lib/notification_settings/subscribable.rb +18 -6
- data/lib/notification_settings/subscriber.rb +19 -7
- data/lib/notification_settings/subscription_library.rb +2 -0
- data/lib/notification_settings/target.rb +16 -5
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 373bfbfd097d24c61d0d6881814ee07e545c6bb109c7b7b9e839e716bc0c4a29
|
4
|
+
data.tar.gz: 64e7f2541ed76c489f8e83136a6e322aa51a187ebdb35bad8edf2819e1fe6e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa397acc0fbe8f45ced4ee1a40d1fc97e59a65010276929089ee33e0d186e8eee69380f4ddb6d4473384340df21a396ef10c484dd149c122484f3ddb846a52af
|
7
|
+
data.tar.gz: d975e08193e541ab11b20be1e83438f63403ffbe89be6a8dfed0e9e91f3f08bfc5b07b80d63fff2734c2cf127e812e8e581500efab5d029e09012334c4487c13
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class NotificationSettings::Setting < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = 'notification_settings_settings'
|
4
|
+
|
5
|
+
include NotificationSettings::SettingLibrary
|
6
|
+
|
7
|
+
serialize :settings, Hash
|
8
|
+
serialize :category_settings, Hash
|
9
|
+
|
10
|
+
belongs_to :object, polymorphic: true, optional: true
|
11
|
+
belongs_to :subscription, optional: true
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class NotificationSettings::Subscription < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = 'notification_settings_subscriptions'
|
4
|
+
|
5
|
+
include NotificationSettings::SubscriptionLibrary
|
6
|
+
|
7
|
+
belongs_to :subscriber, polymorphic: true
|
8
|
+
belongs_to :subscribable, polymorphic: true
|
9
|
+
|
10
|
+
has_many :notifications, class_name: '::Notification'
|
11
|
+
has_one :notification_setting, class_name: 'Setting'
|
12
|
+
|
13
|
+
end
|
@@ -1,14 +1,26 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
1
3
|
module NotificationSettings
|
2
4
|
module Subscribable
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_many :notification_subscriptions, as: :subscribable, class_name: 'NotificationSettings::Subscription', dependent: :destroy
|
10
|
+
has_many :notification_subscribers, through: :notification_subscriptions, source: :subscriber
|
11
|
+
|
12
|
+
include NotificationSettings::Subscribable::InstanceMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
module InstanceMethods
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
17
|
+
def notify_subscribers options = {}
|
18
|
+
options[:object] = self
|
19
|
+
self.notification_subscribers.each do |subscriber|
|
20
|
+
subscriber.notify options
|
21
|
+
end
|
11
22
|
end
|
23
|
+
|
12
24
|
end
|
13
25
|
|
14
26
|
end
|
@@ -1,16 +1,28 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
1
3
|
module NotificationSettings
|
2
4
|
module Subscriber
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_many :notification_subscriptions, as: :subscriber, class_name: 'NotificationSettings::Subscription', dependent: :destroy
|
10
|
+
has_many :notification_subscribables, through: :notification_subscriptions, source: :subscribable
|
6
11
|
|
7
|
-
|
8
|
-
self.notification_subscriptions.create options
|
12
|
+
include NotificationSettings::Subscriber::InstanceMethods
|
9
13
|
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
module InstanceMethods
|
16
|
+
|
17
|
+
def subscribe options = {}
|
18
|
+
self.notification_subscriptions.create options
|
19
|
+
end
|
20
|
+
|
21
|
+
def unsubscribe subscribable
|
22
|
+
subscription = self.notification_subscriptions.find_by subscribable_id: subscribable.id, subscribable_type: subscribable.class.to_s
|
23
|
+
subscription.destroy
|
24
|
+
end
|
25
|
+
|
14
26
|
end
|
15
27
|
|
16
28
|
end
|
@@ -1,14 +1,25 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
1
3
|
module NotificationSettings
|
2
4
|
module Target
|
3
5
|
|
4
|
-
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_one :notification_setting, as: :object, class_name: 'NotificationSettings::Setting', dependent: :destroy
|
10
|
+
after_create_commit :create_notification_setting
|
11
|
+
|
12
|
+
include NotificationSettings::Target::InstanceMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
module InstanceMethods
|
5
16
|
|
6
|
-
|
17
|
+
private
|
7
18
|
|
8
|
-
|
19
|
+
def create_notification_setting
|
20
|
+
self.notification_setting.create!
|
21
|
+
end
|
9
22
|
|
10
|
-
def create_notification_setting
|
11
|
-
self.notification_setting.create!
|
12
23
|
end
|
13
24
|
|
14
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
@@ -24,20 +24,48 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: notification-handler
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - '='
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.
|
61
|
+
version: 1.0.0.beta11
|
34
62
|
type: :runtime
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - '='
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0.
|
68
|
+
version: 1.0.0.beta11
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rspec
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +104,8 @@ files:
|
|
76
104
|
- CHANGELOG.md
|
77
105
|
- LICENSE
|
78
106
|
- README.md
|
107
|
+
- app/models/notification_settings/setting.rb
|
108
|
+
- app/models/notification_settings/subscription.rb
|
79
109
|
- lib/generators/notification_settings/install_generator.rb
|
80
110
|
- lib/generators/templates/install/README.md
|
81
111
|
- lib/generators/templates/install/initializer.rb
|