simple_notifications 1.1.2 → 1.1.3

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: 7feb94255eb57fe400bdd67560d4c9890f2c4866e35c11504005829c12847061
4
- data.tar.gz: c67598078beefc268de6223face3958f9fd892cab80b7f22d693d59fa55c68ad
3
+ metadata.gz: e1326347a5f7506473900145e99a4f850fd12d4087b195cd8c752d1ed3fb7f02
4
+ data.tar.gz: c14be795867013fbd067b477b81b741221c680eea743c604f6ba1f59fdc0a208
5
5
  SHA512:
6
- metadata.gz: 2044a29e6282a2224971b0a7279e46aa610bcc305d92712cc2e6c26861080d7a00840e3a94755942e952550689e6c71c05ac016d7ff6ec8011ebed63d75421ed
7
- data.tar.gz: 586dbee2f0433389a095b79c17fad7cd0f480b7ae8bd60d390e54df37089255dac0ddfdcd06d6dda29c956afc21a770abf3629b8f209faf8a5ef09684af5e2c7
6
+ metadata.gz: 2b5680902fe2b5106059f48301869208c53e20f1fe561d68ed78f080f172e044d01ad7c98503a2061aef3fce1282971ba56939f6a5588b2250134a61ea2aed24
7
+ data.tar.gz: 8ac07714291ac4718140512d34bbbf4969f2af327943cdb64644eecc329e0365ef1033e2e041665dd65c392f3f55584cb314e49ab6aaa6ffb073a5f2b4cb7c23
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_notifications (0.1.0)
4
+ simple_notifications (1.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -84,6 +84,7 @@ Post.notified?
84
84
  **Methods for the [post] object**
85
85
 
86
86
  ```ruby
87
+ post.notify
87
88
  post.notify(sender: :author, receivers: :followers, message: 'My own message')
88
89
  post.notifications
89
90
  post.notifiers
@@ -119,7 +120,8 @@ SimpleNotifications::Record.last.#{receiver_class.name.downcase}_receivers
119
120
  ### Skipping Notification
120
121
 
121
122
  ```ruby
122
- Post.create(content: '123', notify: false)
123
+ Post.create(content: '123', notify_flag: false)
124
+ Post.create(content: '123', notify_flag: nil)
123
125
  ```
124
126
 
125
127
  ### Custom Notification message
@@ -47,7 +47,7 @@ module SimpleNotifications
47
47
  def open_notified_class
48
48
  class_eval do
49
49
  prepend NotificationActions
50
- attr_accessor :message, :notify
50
+ attr_accessor :message, :notify_flag
51
51
 
52
52
  # Define association for the notified model
53
53
  has_many :notifications, class_name: 'SimpleNotifications::Record', as: :entity
@@ -71,8 +71,11 @@ module SimpleNotifications
71
71
  # has_many :read_notificants, through: :read_deliveries, source: :receiver, source_type: 'User'
72
72
  # has_many :unread_notificants, through: :unread_deliveries, source: :receiver, source_type: 'User'
73
73
 
74
+
74
75
  # Callbacks
75
- @@options[:callbacks].each {|_method| send("after_#{_method}_commit", "#{_method}_notification".to_sym)}
76
+ after_create_commit :create_notification, if: proc {@@options[:callbacks].include?(:create)}
77
+ after_update_commit :update_notification, if: proc {@@options[:callbacks].include?(:update)}
78
+ after_destroy_commit :destroy_notification, if: proc {@@options[:callbacks].include?(:destroy)}
76
79
 
77
80
  NotificationActions.module_eval do
78
81
  @@options[:actions].each do |action|
@@ -101,7 +104,9 @@ module SimpleNotifications
101
104
  #post.notify(sender: :author, receivers: :followers, message: 'My Custom logic message')
102
105
  #post.create(content: '', notify: false) -> It does not create the notification.
103
106
  def notify(options = {})
104
- if notify.present? && !!notify
107
+ options[:sender] ||= @@options[:sender]
108
+ options[:receivers] ||= @@options[:receivers]
109
+ if notify_flag.nil? || (!notify_flag.nil? && !!notify_flag)
105
110
  raise 'SimpleNotification::SenderReceiverError' unless @@options[:sender] && @@options[:receivers]
106
111
  @message = options[:message] if options[:message]
107
112
  notification = notifications.build(entity: self, sender: get_obj(options[:sender]), message: default_message(self, get_obj(options[:sender]), 'created'))
@@ -1,3 +1,3 @@
1
1
  module SimpleNotifications
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashish Garg