Class: ActsAsCaesar::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_caesar/objects/notification.rb

Class Method Summary collapse

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(options = {}, &block)
  @subscriptions ||= []
  @subscriptions << { options: options, process: block }
end

.subscriptionsObject



19
20
21
# File 'lib/acts_as_caesar/objects/notification.rb', line 19

def subscriptions
  @subscriptions || []
end