Module: Actionstore::InstanceMethods

Extended by:
ActiveSupport::Concern
Defined in:
lib/actionstore/actionstore.rb

Instance Method Summary collapse

Instance Method Details

#push_append(value) ⇒ Object



45
46
47
# File 'lib/actionstore/actionstore.rb', line 45

def push_append value
  Actionstore::Channel.broadcast_to self, action: 'append', value: value
end

#push_append_into(store_id, value) ⇒ Object



49
50
51
52
# File 'lib/actionstore/actionstore.rb', line 49

def push_append_into store_id, value
  store_id = Actionstore.store_id(store_id)
  Actionstore::Channel.broadcast_to self, store_id: store_id, action: 'append', value: value
end

#push_event(event, data = nil) ⇒ Object



55
56
57
# File 'lib/actionstore/actionstore.rb', line 55

def push_event event, data = nil
  Actionstore::Channel.broadcast_to self, action: event, data: data
end

#push_update(changes) ⇒ Object



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

def push_update changes
  push_update_into nil, changes
end

#push_update_by(key, value, changes) ⇒ Object



36
37
38
# File 'lib/actionstore/actionstore.rb', line 36

def push_update_by key, value, changes
  Actionstore::Channel.broadcast_to self, action: 'update_by', key: key, value: value, changes: changes
end

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



40
41
42
43
# File 'lib/actionstore/actionstore.rb', line 40

def push_update_by_into store_id, key, value, changes
  store_id = Actionstore.store_id(store_id)
  Actionstore::Channel.broadcast_to self, store_id: store_id, action: 'update_by', key: key, value: value, changes: changes
end

#push_update_into(store_id, changes = {}) ⇒ Object



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

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

#serialized_changesObject



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

def serialized_changes
  saved_changes.transform_values(&:last)
end