Sha256: 2280fea51dd5d4a1a4283e96f7cd6ec9eecb175dec92ab5c5e64327e6f5a1698

Contents?: true

Size: 692 Bytes

Versions: 6

Compression:

Stored size: 692 Bytes

Contents

module Pione
  module Model
    # NotificationListenerModel is a model for pione-notification-listener. This
    # manages recipiants lifecycle.
    class NotificationListenerModel < Rootage::Model
      attr_reader :recipients

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

      # Add the URI of recipient.
      def add_recipient(uri)
        @lock.synchronize do
          unless @recipients.include?(uri)
            @recipients << uri
          end
        end
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pione-0.5.0 lib/pione/model/notification-listener-model.rb
pione-0.5.0.alpha.2 lib/pione/model/notification-listener-model.rb
pione-0.5.0.alpha.1 lib/pione/model/notification-listener-model.rb
pione-0.4.2 lib/pione/model/notification-listener-model.rb
pione-0.4.1 lib/pione/model/notification-listener-model.rb
pione-0.4.0 lib/pione/model/notification-listener-model.rb