Class: ActsAsCaesar::Notification
- Inherits:
-
Object
- Object
- ActsAsCaesar::Notification
- Defined in:
- lib/acts_as_caesar/objects/notification.rb
Class Method Summary collapse
-
.publish(object) ⇒ Object
publishes a change to a candidate.
-
.subscribe(options = {}, &block) ⇒ Object
subscribes to changes on a candidate.
- .subscriptions ⇒ Object
Class Method Details
.publish(object) ⇒ Object
publishes a change to a candidate
5 6 7 8 9 10 11 |
# File 'lib/acts_as_caesar/objects/notification.rb', line 5 def publish(object) subscriptions.each do |subscription| if object.key =~ subscription[:options][:key] subscription[:process].yield(object) end end end |
.subscribe(options = {}, &block) ⇒ Object
subscribes to changes on a candidate
14 15 16 17 |
# File 'lib/acts_as_caesar/objects/notification.rb', line 14 def subscribe( = {}, &block) @subscriptions ||= [] @subscriptions << { options: , process: block } end |
.subscriptions ⇒ Object
19 20 21 |
# File 'lib/acts_as_caesar/objects/notification.rb', line 19 def subscriptions @subscriptions || [] end |