Sha256: fac9f1ce4d672604da54ede9a2ff9de872d4edf80e92a107ad47ee0a429cc215

Contents?: true

Size: 454 Bytes

Versions: 4

Compression:

Stored size: 454 Bytes

Contents

module Space
  module Events
    class Subscription
      attr_reader :observer, :types

      def initialize(observer, types)
        @observer = observer
        @types    = types
      end

      def notify(event)
        observer.notify(event) if matches?(event)
      end

      private

        def matches?(event)
          # log [observer.class, types, event].inspect
          types.empty? || types.include?(event)
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
space-0.0.9 lib/space/events/subscription.rb
space-0.0.8 lib/space/events/subscription.rb
space-0.0.7 lib/space/events/subscription.rb
space-0.0.6 lib/space/events/subscription.rb