Module: GetSchwifty::Channel

Included in:
GetSchwiftyChannel
Defined in:
lib/get_schwifty/channel.rb

Overview

:nodoc

Instance Method Summary collapse

Instance Method Details

#actionObject



25
26
27
# File 'lib/get_schwifty/channel.rb', line 25

def action
  route.split("#").last
end

#channel_nameObject



39
40
41
# File 'lib/get_schwifty/channel.rb', line 39

def channel_name
  "get_schwifty:#{schwifty_job_id}"
end

#controllerObject



21
22
23
# File 'lib/get_schwifty/channel.rb', line 21

def controller
  (route.split("#").first + "_cable").camelize
end

#identifiersObject



29
30
31
32
33
# File 'lib/get_schwifty/channel.rb', line 29

def identifiers
  connection.identifiers.collect do |key|
    [key.to_s, send(key)]
  end
end

#renderedObject



13
14
15
# File 'lib/get_schwifty/channel.rb', line 13

def rendered
  Rails.cache.write(channel_name, nil) unless GetSchwifty.allow_rerender
end

#routeObject



17
18
19
# File 'lib/get_schwifty/channel.rb', line 17

def route
  Rails.cache.read(channel_name)
end

#schwifty_job_idObject



35
36
37
# File 'lib/get_schwifty/channel.rb', line 35

def schwifty_job_id
  params[:id]
end

#subscribedObject



6
7
8
9
10
11
# 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