diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2015-01-17 12:02:05 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2015-01-17 12:02:05 +0530 |
commit | 6a78da924960039d17b618f775695682bb9940d9 (patch) | |
tree | 6523e6eb21e64c81c7dd5e3c7d363efab66f94ee /lib/action_cable | |
parent | 955bf93549f336d95862b12079f8b88f99145f8b (diff) | |
download | rails-6a78da924960039d17b618f775695682bb9940d9.tar.gz rails-6a78da924960039d17b618f775695682bb9940d9.tar.bz2 rails-6a78da924960039d17b618f775695682bb9940d9.zip |
More API changes
Diffstat (limited to 'lib/action_cable')
-rw-r--r-- | lib/action_cable/channel/base.rb | 12 | ||||
-rw-r--r-- | lib/action_cable/channel/callbacks.rb | 4 | ||||
-rw-r--r-- | lib/action_cable/server.rb | 1 |
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 6eaade4c8f..3eaa0ceaeb 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -27,7 +27,9 @@ module ActionCable @_active_periodic_timers = [] @params = params - setup + connect + + subscribe end def receive(data) @@ -47,7 +49,7 @@ module ActionCable end protected - def setup + def connect # Override in subclasses end @@ -56,8 +58,10 @@ module ActionCable end def start_periodic_timers - self.class.periodic_timers.each do |method, options| - @_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) { send(method) } + self.class.periodic_timers.each do |callback, options| + @_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do + callback.respond_to?(:call) ? callback.call : send(callback) + end end end diff --git a/lib/action_cable/channel/callbacks.rb b/lib/action_cable/channel/callbacks.rb index cf0246a386..22c6f2d563 100644 --- a/lib/action_cable/channel/callbacks.rb +++ b/lib/action_cable/channel/callbacks.rb @@ -21,8 +21,8 @@ module ActionCable self.on_unsubscribe_callbacks += methods end - def periodic_timer(method, every:) - self.periodic_timers += [ [ method, every: every ] ] + def periodically(callback, every:) + self.periodic_timers += [ [ callback, every: every ] ] end end diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index eeeb50f08c..02cf592ad6 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -54,7 +54,6 @@ module ActionCable if subscription_klass @subscriptions[id_key] = subscription_klass.new(self, id_key, id_options) - @subscriptions[id_key].subscribe else # No channel found end |