Module: ActionCable::Connection::Callbacks
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Defined in: | actioncable/lib/action_cable/connection/callbacks.rb |
Overview
The [before_command](ClassMethods#before_command), [after_command](ClassMethods#after_command), and [around_command](ClassMethods#around_command) callbacks are invoked when sending commands to the client, such as when subscribing, unsubscribing, or performing an action.
Example
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :user
around_command :set_current_account
private
def set_current_account
# Now all channels could use Current.account
Current.set(account: user.account) { yield }
end
end
end
Constant Summary
::ActiveSupport::Callbacks
- Included
::ActiveSupport::Callbacks
- Attributes & Methods
- .__callbacks rw
- #__callbacks readonly
Class Method Summary
::ActiveSupport::DescendantsTracker
- self
::ActiveSupport::Concern
- Extended
class_methods | Define class methods from given block. |
included | Evaluate given block in context of base class, so that you can write class macros here. |
prepended | Evaluate given block in context of base class, so that you can write class macros here. |
append_features, prepend_features |
Instance Method Summary
::ActiveSupport::Callbacks
- Included
#run_callbacks | Runs the callbacks for the given event. |
#halted_callback_hook | A hook invoked every time a before callback is halted. |
DSL Calls
included
[ GitHub ]38 39 40
# File 'actioncable/lib/action_cable/connection/callbacks.rb', line 38
included do define_callbacks :command end
Class Attribute Details
.__callbacks (rw)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 69
class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}
Instance Attribute Details
#__callbacks (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 69
class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}