Class: Actionstore::Channel

Inherits:
ActionCable::Channel::Base
  • Object
show all
Defined in:
lib/actionstore/channel.rb

Instance Method Summary collapse

Instance Method Details

#perform_action(data) ⇒ Object



38
39
40
# File 'lib/actionstore/channel.rb', line 38

def perform_action data
  @subject.send "perform_#{data['action']}", self, *data['args']
end

#push_append(value) ⇒ Object



28
29
30
# File 'lib/actionstore/channel.rb', line 28

def push_append value
  transmit({action: 'append', value: value})
end

#push_append_into(store_id, value) ⇒ Object



32
33
34
35
# File 'lib/actionstore/channel.rb', line 32

def push_append_into store_id, value
  store_id = Actionstore.store_id(store_id)
  transmit({store_id: store_id, action: 'append', value: value})
end

#push_update(changes) ⇒ Object



10
11
12
# File 'lib/actionstore/channel.rb', line 10

def push_update changes
  transmit({action: 'update', changes: changes})
end

#push_update_by(key, value, changes) ⇒ Object



19
20
21
# File 'lib/actionstore/channel.rb', line 19

def push_update_by key, value, changes
  transmit({action: 'update_by', key: key, value: value, changes: changes})
end

#push_update_by_into(store_id, key, value, changes) ⇒ Object



23
24
25
26
# File 'lib/actionstore/channel.rb', line 23

def push_update_by_into store_id, key, value, changes
  store_id = Actionstore.store_id(store_id)
  transmit({store_id: store_id, action: 'update_by', key: key, value: value, changes: changes})
end

#push_update_into(store_id, changes) ⇒ Object



14
15
16
17
# File 'lib/actionstore/channel.rb', line 14

def push_update_into store_id, changes
  store_id = Actionstore.store_id(store_id)
  transmit({store_id: store_id, action: 'update', changes: changes})
end

#subscribedObject



3
4
5
6
7
8
# File 'lib/actionstore/channel.rb', line 3

def subscribed
  @subject = GlobalID::Locator.locate_signed params[:sgid]
  return reject unless @subject
  stream_for @subject
  @subject.subscribed self if @subject.respond_to? :subscribed
end

#unsubscribedObject



42
43
44
# File 'lib/actionstore/channel.rb', line 42

def unsubscribed
  @subject.unsubscribed self if @subject.respond_to? :unsubscribed
end