Class: Fragmentary::Subscription::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/fragmentary/subscription.rb

Constant Summary collapse

@@all =

Allow only one proxy per publisher; the proxy is responsible for subscribing to the publisher on behalf of individual subscriptions and calling handlers on each of them whenever the publisher broadcasts.

Hash.new do |h, key|
  h[key] = Proxy.new(:publisher => key.constantize)
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#publisherObject (readonly)

Returns the value of attribute publisher.



14
15
16
# File 'lib/fragmentary/subscription.rb', line 14

def publisher
  @publisher
end

Class Method Details

.fetch(key) ⇒ Object



16
17
18
# File 'lib/fragmentary/subscription.rb', line 16

def self.fetch(key)
  @@all[key]
end

Instance Method Details

#register(subscription) ⇒ Object



20
21
22
# File 'lib/fragmentary/subscription.rb', line 20

def register(subscription)
  subscriptions << subscription if subscription.is_a? Subscription
end