entangled 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/entangled/model.rb +9 -2
- data/lib/entangled/version.rb +1 -1
- data/spec/models/channels_spec.rb +50 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c90e25e9bc6ff181667253af48ad1b36235425c
|
4
|
+
data.tar.gz: 21dfcd7b48ed82e22056e8528d196962f6c93ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f037193337876ec1bc462903f3a05fd9960ef9cc94391772ba33bf754b53405786000a84928f0673d34a56c910ec855a632aceb13d6cd903fadcc81ed072a5
|
7
|
+
data.tar.gz: 68e195848fd01c5349fa81d540dbf23b28adac42fc6210e71c1282f67a6bc2e29dfebbc33408d162edd73bf5c0908f6015a09249d5654f13058f727d20f8dbc8
|
data/README.md
CHANGED
@@ -270,7 +270,6 @@ The gem relies heavily on convention over configuration and currently only works
|
|
270
270
|
## Development Priorities
|
271
271
|
The following features are to be implemented next:
|
272
272
|
|
273
|
-
- Do not build channels for nil parents
|
274
273
|
- Make prefix of create path `create_message` instead of `create_messages`
|
275
274
|
- Support `belongsTo` in front end
|
276
275
|
- Support `has_one` association in back end and front end
|
data/lib/entangled/model.rb
CHANGED
@@ -82,6 +82,11 @@ module Entangled
|
|
82
82
|
# recursively
|
83
83
|
def channels(tail = '')
|
84
84
|
channels = []
|
85
|
+
|
86
|
+
# If the record is not persisted, it should not have
|
87
|
+
# any channels
|
88
|
+
return channels unless persisted?
|
89
|
+
|
85
90
|
plural_name = self.class.name.underscore.pluralize
|
86
91
|
|
87
92
|
# Add collection channel for child only. If the tails
|
@@ -131,11 +136,13 @@ module Entangled
|
|
131
136
|
}.to_json
|
132
137
|
end
|
133
138
|
|
134
|
-
# Find parent classes from belongs_to associations
|
139
|
+
# Find parent classes from belongs_to associations that
|
140
|
+
# are not nil
|
135
141
|
def parents
|
136
142
|
self.class.
|
137
143
|
reflect_on_all_associations(:belongs_to).
|
138
|
-
map{ |a| send(a.name) }
|
144
|
+
map{ |a| send(a.name) }.
|
145
|
+
reject(&:nil?)
|
139
146
|
end
|
140
147
|
end
|
141
148
|
|
data/lib/entangled/version.rb
CHANGED
@@ -14,6 +14,16 @@ RSpec.describe 'Channels', type: :model do
|
|
14
14
|
|
15
15
|
let!(:child) { Child.create(parent_id: parent.id) }
|
16
16
|
|
17
|
+
# Child without parents
|
18
|
+
let!(:orphan) do
|
19
|
+
child = Child.new
|
20
|
+
child.save(validate: false)
|
21
|
+
child
|
22
|
+
end
|
23
|
+
|
24
|
+
# Child that's not persisted
|
25
|
+
let!(:fetus) { Child.new }
|
26
|
+
|
17
27
|
describe "grandmother's channels" do
|
18
28
|
it 'has two channels' do
|
19
29
|
expect(grandmother.channels.size).to eq 2
|
@@ -24,7 +34,8 @@ RSpec.describe 'Channels', type: :model do
|
|
24
34
|
end
|
25
35
|
|
26
36
|
it 'has a member channel' do
|
27
|
-
|
37
|
+
channel = "/grandmothers/#{grandmother.to_param}"
|
38
|
+
expect(grandmother.channels).to include channel
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
@@ -38,7 +49,8 @@ RSpec.describe 'Channels', type: :model do
|
|
38
49
|
end
|
39
50
|
|
40
51
|
it 'has a member channel' do
|
41
|
-
|
52
|
+
channel = "/grandfathers/#{grandfather.to_param}"
|
53
|
+
expect(grandfather.channels).to include channel
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
@@ -56,19 +68,25 @@ RSpec.describe 'Channels', type: :model do
|
|
56
68
|
end
|
57
69
|
|
58
70
|
it 'has a collection channel nested under its grandmother' do
|
59
|
-
|
71
|
+
channel = "/grandmothers/#{grandmother.to_param}/parents"
|
72
|
+
expect(parent.channels).to include channel
|
60
73
|
end
|
61
74
|
|
62
75
|
it 'has a member channel nested under its grandmother' do
|
63
|
-
|
76
|
+
channel = "/grandmothers/#{grandmother.to_param}"\
|
77
|
+
"/parents/#{parent.to_param}"
|
78
|
+
expect(parent.channels).to include channel
|
64
79
|
end
|
65
80
|
|
66
81
|
it 'has a collection channel nested under its grandfather' do
|
67
|
-
|
82
|
+
channel = "/grandfathers/#{grandfather.to_param}/parents"
|
83
|
+
expect(parent.channels).to include channel
|
68
84
|
end
|
69
85
|
|
70
86
|
it 'has a member channel nested under its grandfather' do
|
71
|
-
|
87
|
+
channel = "/grandfathers/#{grandfather.to_param}"\
|
88
|
+
"/parents/#{parent.to_param}"
|
89
|
+
expect(parent.channels).to include channel
|
72
90
|
end
|
73
91
|
end
|
74
92
|
|
@@ -90,23 +108,44 @@ RSpec.describe 'Channels', type: :model do
|
|
90
108
|
end
|
91
109
|
|
92
110
|
it 'has a member channel nested under its parent' do
|
93
|
-
|
111
|
+
channel = "/parents/#{parent.to_param}/children/#{child.to_param}"
|
112
|
+
expect(child.channels).to include channel
|
94
113
|
end
|
95
114
|
|
96
115
|
it 'has a collection channel nested under its parent and grandmother' do
|
97
|
-
|
116
|
+
channel = "/grandmothers/#{grandmother.to_param}"\
|
117
|
+
"/parents/#{parent.to_param}/children"
|
118
|
+
expect(child.channels).to include channel
|
98
119
|
end
|
99
120
|
|
100
121
|
it 'has a member channel nested under its parent and grandmother' do
|
101
|
-
|
122
|
+
channel = "/grandmothers/#{grandmother.to_param}"\
|
123
|
+
"/parents/#{parent.to_param}/children/#{child.to_param}"
|
124
|
+
expect(child.channels).to include channel
|
102
125
|
end
|
103
126
|
|
104
127
|
it 'has a collection channel nested under its parent and grandfather' do
|
105
|
-
|
128
|
+
channel = "/grandfathers/#{grandfather.to_param}"\
|
129
|
+
"/parents/#{parent.to_param}/children"
|
130
|
+
expect(child.channels).to include channel
|
106
131
|
end
|
107
132
|
|
108
133
|
it 'has a member channel nested under its parent and grandfather' do
|
109
|
-
|
134
|
+
channel = "/grandfathers/#{grandfather.to_param}"\
|
135
|
+
"/parents/#{parent.to_param}/children/#{child.to_param}"
|
136
|
+
expect(child.channels).to include channel
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "orphan's channels" do
|
141
|
+
it 'does not have any parent channels since it has no parent' do
|
142
|
+
expect(orphan.channels.size).to eq 2
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "fetus's channel" do
|
147
|
+
it 'does not have any channels since it is not persisted' do
|
148
|
+
expect(fetus.channels).to be_empty
|
110
149
|
end
|
111
150
|
end
|
112
151
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entangled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Charles Hackethal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
version: '0'
|
286
286
|
requirements: []
|
287
287
|
rubyforge_project:
|
288
|
-
rubygems_version: 2.
|
288
|
+
rubygems_version: 2.2.2
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: Makes Rails real time through websockets.
|