diff options
Diffstat (limited to 'lib/action_cable/worker.rb')
-rw-r--r-- | lib/action_cable/worker.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/action_cable/worker.rb b/lib/action_cable/worker.rb new file mode 100644 index 0000000000..6687af43a0 --- /dev/null +++ b/lib/action_cable/worker.rb @@ -0,0 +1,21 @@ +module ActionCable + class Worker + include ActiveSupport::Callbacks + include Celluloid + + define_callbacks :work + + def invoke(receiver, method, *args) + run_callbacks :work do + receiver.send method, *args + end + end + + def run_periodic_timer(channel, callback) + run_callbacks :work do + callback.respond_to?(:call) ? channel.instance_exec(&callback) : channel.send(callback) + end + end + + end +end |