Class: Renalware::Broadcasting::Subscriber
- Inherits:
-
Object
- Object
- Renalware::Broadcasting::Subscriber
- Defined in:
- app/models/concerns/renalware/broadcasting.rb
Instance Attribute Summary collapse
-
#async ⇒ Object
(also: #async?)
readonly
Returns the value of attribute async.
-
#klass_name ⇒ Object
readonly
Returns the value of attribute klass_name.
Instance Method Summary collapse
-
#initialize(klass_name, async: false) ⇒ Subscriber
constructor
A new instance of Subscriber.
-
#instance ⇒ Object
Note that when using the wisper-activejob gem (so we can use delayed_job for instance) we subscribe the class not an instance, and the subscriber must have class methods matching the event names it wants to handle.
- #klass ⇒ Object
Constructor Details
#initialize(klass_name, async: false) ⇒ Subscriber
Returns a new instance of Subscriber.
14 15 16 17 |
# File 'app/models/concerns/renalware/broadcasting.rb', line 14 def initialize(klass_name, async: false) @klass_name = klass_name @async = async end |
Instance Attribute Details
#async ⇒ Object (readonly) Also known as: async?
Returns the value of attribute async.
11 12 13 |
# File 'app/models/concerns/renalware/broadcasting.rb', line 11 def async @async end |
#klass_name ⇒ Object (readonly)
Returns the value of attribute klass_name.
11 12 13 |
# File 'app/models/concerns/renalware/broadcasting.rb', line 11 def klass_name @klass_name end |
Instance Method Details
#instance ⇒ Object
Note that when using the wisper-activejob gem (so we can use delayed_job for instance) we subscribe the class not an instance, and the subscriber must have class methods matching the event names it wants to handle. github.com/krisleech/wisper-activejob
23 24 25 |
# File 'app/models/concerns/renalware/broadcasting.rb', line 23 def instance async? ? klass : klass.new end |
#klass ⇒ Object
27 28 29 |
# File 'app/models/concerns/renalware/broadcasting.rb', line 27 def klass klass_name.to_s.constantize end |