Class: Stimul8::ComponentChannel

Inherits:
ApplicationCable::Channel show all
Defined in:
app/channels/stimul8/component_channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



3
4
5
# File 'app/channels/stimul8/component_channel.rb', line 3

def component
  @component
end

Instance Method Details

#action(data = {}) ⇒ Object



13
14
15
16
# File 'app/channels/stimul8/component_channel.rb', line 13

def action data = {}
  action = data.delete("action")
  @component.send(action.to_sym, **data.symbolize_keys)
end

#subscribedObject



5
6
7
# File 'app/channels/stimul8/component_channel.rb', line 5

def subscribed
  @component = Stimul8::Component.recreate params[:component_class], params[:component_id], context: context
end

#unsubscribedObject



9
10
11
# File 'app/channels/stimul8/component_channel.rb', line 9

def unsubscribed
  @component = nil
end