notification-settings 1.0.0.beta10 → 1.0.0.beta11

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: 0e509c85a15e43da7caffe6b2929d10ae6bf5046946a28d904407c1ae8fb3b04
4
- data.tar.gz: a2e48422a49cccbd6c20d5c500a5f390c85c4097201178d8e89d9a43c1be77bf
3
+ metadata.gz: 373bfbfd097d24c61d0d6881814ee07e545c6bb109c7b7b9e839e716bc0c4a29
4
+ data.tar.gz: 64e7f2541ed76c489f8e83136a6e322aa51a187ebdb35bad8edf2819e1fe6e86
5
5
  SHA512:
6
- metadata.gz: 400ae8bdd7b6aa764b50d6d0859f642aae43e98bb458a7e50d25b3edec3258e5c707d75234ae1863298d39a33d58fb73b5e84048bb25ce2217cc00fcbe6f0df0
7
- data.tar.gz: 7622af93a27d60aa76fa889a4af851898c887788209ca8b969a10a7a8ec2c6eb62389449b913a8884ce6664d3974143fb5d34b6954d91b53d223696ffa54bf27
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,4 +1,5 @@
1
1
  require 'rails/railtie'
2
+ require 'active_record'
2
3
 
3
4
  module NotificationSettings
4
5
  class Engine < ::Rails::Engine
@@ -1,3 +1,6 @@
1
+ require 'notification-handler'
2
+ require 'active_support'
3
+
1
4
  module NotificationSettings
2
5
  module NotificationLibrary
3
6
 
@@ -1,3 +1,6 @@
1
+ require 'notification-handler'
2
+ require 'active_support'
3
+
1
4
  module NotificationSettings
2
5
  module NotificationScopes
3
6
 
@@ -1,3 +1,5 @@
1
+ require 'active_support'
2
+
1
3
  module NotificationSettings
2
4
  module SettingLibrary
3
5
 
@@ -1,14 +1,26 @@
1
+ require 'active_support'
2
+
1
3
  module NotificationSettings
2
4
  module Subscribable
3
5
 
4
- has_many :notification_subscriptions, as: :subscribable, class_name: 'NotificationSettings::Subscription', dependent: :destroy
5
- has_many :notification_subscribers, through: :notification_subscriptions, source: :subscriber
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
- def notify_subscribers options = {}
8
- options[:object] = self
9
- self.notification_subscribers.each do |subscriber|
10
- subscriber.notify options
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
- has_many :notification_subscriptions, as: :subscriber, class_name: 'NotificationSettings::Subscription', dependent: :destroy
5
- has_many :notification_subscribables, through: :notification_subscriptions, source: :subscribable
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
- def subscribe options = {}
8
- self.notification_subscriptions.create options
12
+ include NotificationSettings::Subscriber::InstanceMethods
9
13
  end
10
14
 
11
- def unsubscribe subscribable
12
- subscription = self.notification_subscriptions.find_by subscribable_id: subscribable.id, subscribable_type: subscribable.class.to_s
13
- subscription.destroy
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,3 +1,5 @@
1
+ require 'active_support'
2
+
1
3
  module NotificationSettings
2
4
  module SubscriptionLibrary
3
5
 
@@ -1,14 +1,25 @@
1
+ require 'active_support'
2
+
1
3
  module NotificationSettings
2
4
  module Target
3
5
 
4
- has_one :notification_setting, as: :object, class_name: 'NotificationSettings::Setting', dependent: :destroy
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
- after_create_commit :create_notification_setting
17
+ private
7
18
 
8
- private
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.beta10
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.beta10
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.beta10
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