Class: Pione::Model::NotificationListenerModel

Inherits:
Rootage::Model show all
Defined in:
lib/pione/model/notification-listener-model.rb

Overview

NotificationListenerModel is a model for pione-notification-listener. This manages recipiants lifecycle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rootage::Model

#[], #[]=, #specified?, #specify, #to_hash

Constructor Details

#initializeNotificationListenerModel

Returns a new instance of NotificationListenerModel.



8
9
10
11
12
# File 'lib/pione/model/notification-listener-model.rb', line 8

def initialize
  super
  @recipients = []
  @lock = Mutex.new
end

Instance Attribute Details

#recipientsObject (readonly)

Returns the value of attribute recipients.



6
7
8
# File 'lib/pione/model/notification-listener-model.rb', line 6

def recipients
  @recipients
end

Instance Method Details

#add_recipient(uri) ⇒ Object

Add the URI of recipient.



15
16
17
18
19
20
21
# File 'lib/pione/model/notification-listener-model.rb', line 15

def add_recipient(uri)
  @lock.synchronize do
    unless @recipients.include?(uri)
      @recipients << uri
    end
  end
end

#delete_recipient(*uris) ⇒ Object

Delete the recipients.



24
25
26
# File 'lib/pione/model/notification-listener-model.rb', line 24

def delete_recipient(*uris)
  @lock.synchronize {uris.each {|uri| @recipients.delete(uri)}}
end