Sha256: 830c4ed5063b7ac714a1f5ce09f988816f8e19b093de9ab9e72fd6c0664e785e

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

module Space
  module Events
    autoload :Subscription, 'space/events/subscription'
    autoload :Sources,      'space/events/sources'

    class << self
      def sources
        @sources ||= Sources.new(self)
      end

      def subscriptions
        @subscriptions ||= []
      end

      def events
        @events ||= []
      end

      def subscribe(observer, *types)
        subscriptions << Subscription.new(observer, types)
      end

      def notify(event)
        # log event
        subscriptions.each do |subscription|
          subscription.notify(event)
        end
      end
    end

    def notify(*args)
      Events.notify(*args)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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