Class: DDP::Server::Protocol::Data::Subscription
- Inherits:
-
Object
- Object
- DDP::Server::Protocol::Data::Subscription
- Includes:
- Celluloid
- Defined in:
- lib/ddp/server/protocol/data.rb
Overview
Actor that asynchronously monitors a collection
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#stopped ⇒ Object
(also: #stopped?)
readonly
Returns the value of attribute stopped.
Instance Method Summary collapse
-
#initialize(listener, id, name, query) ⇒ Subscription
constructor
A new instance of Subscription.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(listener, id, name, query) ⇒ Subscription
Returns a new instance of Subscription.
90 91 92 93 94 95 96 |
# File 'lib/ddp/server/protocol/data.rb', line 90 def initialize(listener, id, name, query) @stopped = false @name = name @listener = listener @id = id @query = query end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
87 88 89 |
# File 'lib/ddp/server/protocol/data.rb', line 87 def id @id end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
87 88 89 |
# File 'lib/ddp/server/protocol/data.rb', line 87 def listener @listener end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
87 88 89 |
# File 'lib/ddp/server/protocol/data.rb', line 87 def name @name end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
87 88 89 |
# File 'lib/ddp/server/protocol/data.rb', line 87 def query @query end |
#stopped ⇒ Object (readonly) Also known as: stopped?
Returns the value of attribute stopped.
87 88 89 |
# File 'lib/ddp/server/protocol/data.rb', line 87 def stopped @stopped end |
Instance Method Details
#start ⇒ Object
98 99 100 101 102 103 |
# File 'lib/ddp/server/protocol/data.rb', line 98 def start query.call do |old_value, new_value| listener.subscription_update(id, old_value, new_value) break if stopped? end end |
#stop ⇒ Object
105 106 107 |
# File 'lib/ddp/server/protocol/data.rb', line 105 def stop @stopped = true end |