class Nuge::Pusher

Attributes

clients[R]
expander[W]

Public Class Methods

clients() click to toggle source
# File lib/nuge/pusher.rb, line 9
def self.clients
  @clients ||= Set.new
end
clients=(clients) click to toggle source
# File lib/nuge/pusher.rb, line 5
def self.clients=(clients)
  @clients = Set.new(clients)
end
new(clients = nil) click to toggle source
# File lib/nuge/pusher.rb, line 16
def initialize(clients = nil)
  @clients = Set.new(clients || self.class.clients)
end

Public Instance Methods

expanded(*objects) click to toggle source
# File lib/nuge/pusher.rb, line 36
def expanded(*objects)
  objects.flatten.map { |obj| expander.call(obj) }
end
expander() click to toggle source
# File lib/nuge/pusher.rb, line 32
def expander
  @expander ||= -> (obj) { obj }
end
push(ids, message) click to toggle source
# File lib/nuge/pusher.rb, line 20
def push(ids, message)
  clients.each { |client| client.push(expanded(ids), message) }
end
register(id, options = {}) click to toggle source
# File lib/nuge/pusher.rb, line 24
def register(id, options = {})
  clients.each { |client| client.register(expanded(id).first, options) }
end
unregister(id, options = {}) click to toggle source
# File lib/nuge/pusher.rb, line 28
def unregister(id, options = {})
  clients.each { |client| client.unregister(expanded(id).first, options) }
end