Class: Nuge::Pusher
- Inherits:
-
Object
- Object
- Nuge::Pusher
- Defined in:
- lib/nuge/pusher.rb
Instance Attribute Summary collapse
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
- #expander ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
- #expanded(*objects) ⇒ Object
-
#initialize(clients = nil) ⇒ Pusher
constructor
A new instance of Pusher.
- #push(ids, message) ⇒ Object
- #register(id, options = {}) ⇒ Object
- #unregister(id, options = {}) ⇒ Object
Constructor Details
#initialize(clients = nil) ⇒ Pusher
Returns a new instance of Pusher.
16 17 18 |
# File 'lib/nuge/pusher.rb', line 16 def initialize(clients = nil) @clients = Set.new(clients || self.class.clients) end |
Instance Attribute Details
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
13 14 15 |
# File 'lib/nuge/pusher.rb', line 13 def clients @clients end |
#expander ⇒ Object
32 33 34 |
# File 'lib/nuge/pusher.rb', line 32 def @expander ||= -> (obj) { obj } end |
Class Method Details
.clients ⇒ Object
9 10 11 |
# File 'lib/nuge/pusher.rb', line 9 def self.clients @clients ||= Set.new end |
.clients=(clients) ⇒ Object
5 6 7 |
# File 'lib/nuge/pusher.rb', line 5 def self.clients=(clients) @clients = Set.new(clients) end |
Instance Method Details
#expanded(*objects) ⇒ Object
36 37 38 |
# File 'lib/nuge/pusher.rb', line 36 def (*objects) objects.flatten.map { |obj| .call(obj) } end |
#push(ids, message) ⇒ Object
20 21 22 |
# File 'lib/nuge/pusher.rb', line 20 def push(ids, ) clients.each { |client| client.push((ids), ) } end |
#register(id, options = {}) ⇒ Object
24 25 26 |
# File 'lib/nuge/pusher.rb', line 24 def register(id, = {}) clients.each { |client| client.register((id).first, ) } end |
#unregister(id, options = {}) ⇒ Object
28 29 30 |
# File 'lib/nuge/pusher.rb', line 28 def unregister(id, = {}) clients.each { |client| client.unregister((id).first, ) } end |