Class: Pione::Model::NotificationListenerModel
- Inherits:
-
Rootage::Model
- Object
- Rootage::Model
- Pione::Model::NotificationListenerModel
- 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
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
Instance Method Summary collapse
-
#add_recipient(uri) ⇒ Object
Add the URI of recipient.
-
#delete_recipient(*uris) ⇒ Object
Delete the recipients.
-
#initialize ⇒ NotificationListenerModel
constructor
A new instance of NotificationListenerModel.
Methods inherited from Rootage::Model
#[], #[]=, #specified?, #specify, #to_hash
Constructor Details
#initialize ⇒ NotificationListenerModel
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
#recipients ⇒ Object (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 |