module GetSchwifty::Channel

:nodoc

Public Instance Methods

action() click to toggle source
# File lib/get_schwifty/channel.rb, line 25
def action
  route.split("#").last
end
channel_name() click to toggle source
# File lib/get_schwifty/channel.rb, line 39
def channel_name
  "get_schwifty:#{schwifty_job_id}"
end
controller() click to toggle source
# File lib/get_schwifty/channel.rb, line 21
def controller
  (route.split("#").first + "_cable").camelize
end
identifiers() click to toggle source
# File lib/get_schwifty/channel.rb, line 29
def identifiers
  connection.identifiers.collect do |key|
    [key.to_s, send(key)]
  end
end
rendered() click to toggle source
# File lib/get_schwifty/channel.rb, line 13
def rendered
  Rails.cache.write(channel_name, nil) unless GetSchwifty.allow_rerender
end
route() click to toggle source
# File lib/get_schwifty/channel.rb, line 17
def route
  Rails.cache.read(channel_name)
end
schwifty_job_id() click to toggle source
# File lib/get_schwifty/channel.rb, line 35
def schwifty_job_id
  params[:id]
end
subscribed() click to toggle source
# File lib/get_schwifty/channel.rb, line 6
def subscribed
  reject if route.blank?

  stream_from channel_name
  GetSchwiftyRunnerJob.perform_later(channel_name, controller, action, params, *identifiers.flatten)
end