Module: ActionCable::Channel::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/channel/callbacks.rb | 
Overview
Action Cable ::ActionCable::Channel provides callback hooks that are invoked during the life
cycle of a channel:
- before_subscribe
 - after_subscribe (aliased as on_subscribe)
 - before_unsubscribe
 - after_unsubscribe (aliased as on_unsubscribe)
 
Example
class ChatChannel < ApplicationCable::Channel
  after_subscribe :, unless: :subscription_rejected?
  after_subscribe :track_subscription
  private
    def 
      broadcast_to(...)
    end
    def track_subscription
      # ...
    end
end
  Constant Summary
- 
    INTERNAL_METHODS =
    Internal use only
    
# File 'actioncable/lib/action_cable/channel/callbacks.rb', line 42[:_run_subscribe_callbacks, :_run_unsubscribe_callbacks]
 
::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 ]44 45 46 47
# File 'actioncable/lib/action_cable/channel/callbacks.rb', line 44
included do define_callbacks :subscribe define_callbacks :unsubscribe end
Class Attribute Details
.__callbacks (rw)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 70
class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}
Instance Attribute Details
#__callbacks (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 70
class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}