1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/action_cable/channel/callbacks.rb
2015-01-14 21:59:47 +05:30

32 lines
No EOL
734 B
Ruby

module ActionCable
module Channel
module Callbacks
extend ActiveSupport::Concern
included do
class_attribute :on_subscribe_callbacks, :on_unsubscribe_callbacks, :periodic_timers, :instance_reader => false
self.on_subscribe_callbacks = []
self.on_unsubscribe_callbacks = []
self.periodic_timers = []
end
module ClassMethods
def on_subscribe(*methods)
self.on_subscribe_callbacks += methods
end
def on_unsubscribe(*methods)
self.on_unsubscribe_callbacks += methods
end
def periodic_timer(method, every:)
self.periodic_timers += [ [ method, every: every ] ]
end
end
end
end
end