action_cable_notifications 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10d38c1784eed12e550b74daac11de60c16641eb
4
- data.tar.gz: 82afbcf44adfb536f9900d94a60d669e800e9bfc
3
+ metadata.gz: 93a9012143b6b7d56623ffc5fa9f1af2b7d6e903
4
+ data.tar.gz: 33e6cc435a5e149a7899a83c97aced3c3815d841
5
5
  SHA512:
6
- metadata.gz: 7dd2c4f06d394aaa5d7562b5fb1a542851ff7a6978658aaf43cc5223d25bc11dc36fd573fe0da1e47bbda95b5c047ccf37ae22fcda18eb440c2c5bc6eae30d24
7
- data.tar.gz: 479f92747da68fbedaf87733f742085f94e87c5bb3c084d3eadb751ddf23e61ae8429bc821fb835ab1bc1a0d9d1604d07fbc982db1e5d16d84162944d3dff597
6
+ metadata.gz: 90f782dc30ebf6f14d961e020e1965b713305eba0b6ab7775441bc180afb6ad3b857ad84f629b190a9a41078f9df6b11ead947c867cbad79b15380286255bae9
7
+ data.tar.gz: c6f608b919a1ac36263908afbf0132dbb7044c3f214b706600c625c5ffefc5be1182eb6afd49256d1da7404ef9c317f4778feb02f591f873b5f0fc188d5c5c79
@@ -38,26 +38,34 @@ class CableNotifications
38
38
  @collections[collection] = []
39
39
 
40
40
  collection_add: (packet, collection) ->
41
- @collections[collection || packet.collection] = packet.data
41
+ for index, row of packet.data
42
+ @collections[collection || packet.collection].push( row )
42
43
 
43
44
  collection_remove: (packet, collection) ->
44
45
  console.warn 'Method not implemented: collection_remove '
45
46
 
46
- added: (packet, collection) ->
47
+ create: (packet, collection) ->
47
48
  data = processPacketHelper(packet, collection)
48
49
  if data.record
49
50
  console.warn 'Expected not to find a document already present for an add: ' + data.record
50
51
  else
51
52
  data.collection.push(packet.data)
52
53
 
53
- changed: (packet, collection) ->
54
+ update: (packet, collection) ->
54
55
  data = processPacketHelper(packet, collection)
55
56
  if !data.record
56
57
  console.warn 'Expected to find a document to change'
57
58
  else if !_.isEmpty(packet.data)
58
59
  _.extend(data.record, packet.data)
59
60
 
60
- removed: (packet, collection) ->
61
+ update_many: (packet, collection) ->
62
+ local_collection = @collections[collection || packet.collection]
63
+ _.each packet.data, (fields) ->
64
+ record = _.findIndex(local_collection, (r) -> r.id == fields.id)
65
+ if record
66
+ _.extend(local_collection[index], fields)
67
+
68
+ destroy: (packet, collection) ->
61
69
  data = processPacketHelper(packet, collection)
62
70
  if !data.record
63
71
  console.warn 'Expected to find a document to remove'
@@ -76,7 +76,7 @@ module ActionCableNotifications
76
76
  if self.class.scoped_collection(options[:scope]).where(id: self.id)
77
77
  ActionCable.server.broadcast broadcasting,
78
78
  collection: self.model_name.collection,
79
- msg: 'added',
79
+ msg: 'create',
80
80
  id: self.id,
81
81
  data: self
82
82
  end
@@ -106,7 +106,7 @@ module ActionCableNotifications
106
106
  # performance for large data sets where only a sub
107
107
  ActionCable.server.broadcast broadcasting,
108
108
  collection: self.model_name.collection,
109
- msg: 'changed',
109
+ msg: 'update',
110
110
  id: self.id,
111
111
  data: changes
112
112
  end
@@ -124,7 +124,7 @@ module ActionCableNotifications
124
124
  if self.class.scoped_collection(options[:scope]).where(id: self.id)
125
125
  ActionCable.server.broadcast broadcasting,
126
126
  collection: self.model_name.collection,
127
- msg: 'removed',
127
+ msg: 'destroy',
128
128
  id: self.id
129
129
  end
130
130
  end
@@ -1,3 +1,3 @@
1
1
  module ActionCableNotifications
2
- VERSION = '0.1.9'
2
+ VERSION = '0.1.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_cable_notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - ByS Sistemas de Control
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-05 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails