Class: CelluloidIOPGListener::Examples::ListenerClientByInheritance
- Inherits:
-
Client
- Object
- Client
- CelluloidIOPGListener::Examples::ListenerClientByInheritance
- Defined in:
- lib/celluloid-io-pg-listener/examples/listener_client_by_inheritance.rb
Instance Attribute Summary
Attributes inherited from Client
Instance Method Summary collapse
-
#foo_bar(channel, payload) ⇒ Object
callback_method does not accept a block parameter.
-
#initialize(a = nil, b = nil, bus: nil, fat: nil, **args) ⇒ ListenerClientByInheritance
constructor
When you are: * sub-classing a class that includes the Client and defines initialize.
Methods inherited from Client
Constructor Details
#initialize(a = nil, b = nil, bus: nil, fat: nil, **args) ⇒ ListenerClientByInheritance
When you are:
* sub-classing a class that includes the Client and defines initialize
If you
* defining a custom / overridden initialize method in the sub-class
The Client may not work.
* the initialize overrides may happen out of normal order,
and may not work as expected.
Working Example of overridden initialize follows!
18 19 20 21 22 |
# File 'lib/celluloid-io-pg-listener/examples/listener_client_by_inheritance.rb', line 18 def initialize(a = nil, b = nil, bus: nil, fat: nil, **args) # Unlike in the original class, the prepends have been usurped since this overridden method is now highest precedence. super(subclassed_client: true, **args) # The initialize overrides will be called by super, and thus you have to be careful how you pass on the arguments to super. end |
Instance Method Details
#foo_bar(channel, payload) ⇒ Object
callback_method does not accept a block parameter
25 26 27 28 29 30 |
# File 'lib/celluloid-io-pg-listener/examples/listener_client_by_inheritance.rb', line 25 def (channel, payload) # <-- within the unlisten_wrapper's block if :foo_bar is the callback_method debug "#{self.class}##{__method__} channel: #{channel}" debug "#{self.class}##{__method__} payload: #{payload}" raise RuntimeError, "This example only works on the users_insert channel, you are notifying #{channel} with #{payload}" unless channel == "users_insert" end |