distant 0.1.2 → 0.1.3
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/Gemfile.lock +1 -1
- data/distant.gemspec +1 -1
- data/lib/distant/base.rb +16 -8
- data/spec/client/base_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04f23a0783899b668d29d4c7d9b69094bba82ab7
|
4
|
+
data.tar.gz: c4ec21cd7156223d2913e623c02beb75acc3260d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8814fe8479e43c40afc77f87cf26f7d12531ccad28b0ff1d501a67ac2b203d25e7f4ef0a623adb68199235f606aafafb8d98e4723c57dbccbc16da29d06082a1
|
7
|
+
data.tar.gz: 2f74f38442f84652a3589284daff9caf43545ddf70075960a09f7da3de347f5b88ba5b8357da2d62e8c356946d54f5380133910892e293df53609df450423fc1
|
data/Gemfile.lock
CHANGED
data/distant.gemspec
CHANGED
data/lib/distant/base.rb
CHANGED
@@ -18,6 +18,14 @@ module Distant
|
|
18
18
|
self.class.connection
|
19
19
|
end
|
20
20
|
|
21
|
+
def has_many?(plural)
|
22
|
+
self.class.has_many_rels.include? plural.to_sym
|
23
|
+
end
|
24
|
+
|
25
|
+
def belongs_to?(singular)
|
26
|
+
self.class.belongs_to_rels.include? singular.to_sym
|
27
|
+
end
|
28
|
+
|
21
29
|
module ClassMethods
|
22
30
|
def init_class_vars
|
23
31
|
@has_many = [ ]
|
@@ -28,6 +36,14 @@ module Distant
|
|
28
36
|
@@connection ||= Distant::Connection.new( Distant.config )
|
29
37
|
end
|
30
38
|
|
39
|
+
def has_many_rels
|
40
|
+
@has_many
|
41
|
+
end
|
42
|
+
|
43
|
+
def belongs_to_rels
|
44
|
+
@belongs_to
|
45
|
+
end
|
46
|
+
|
31
47
|
def marshal(data)
|
32
48
|
self.new(data)
|
33
49
|
end
|
@@ -58,14 +74,6 @@ module Distant
|
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
61
|
-
def has_many?(plural)
|
62
|
-
@has_many.include? plural.to_sym
|
63
|
-
end
|
64
|
-
|
65
|
-
def belongs_to?(singular)
|
66
|
-
@belongs_to.include? singular.to_sym
|
67
|
-
end
|
68
|
-
|
69
77
|
def belongs_to(singular, route)
|
70
78
|
@belongs_to << singular.to_sym
|
71
79
|
define_method(singular) do
|
data/spec/client/base_spec.rb
CHANGED
@@ -228,12 +228,12 @@ describe Distant::Base do
|
|
228
228
|
context 'when the thing' do
|
229
229
|
context 'does have many other_things' do
|
230
230
|
it 'returns true' do
|
231
|
-
expect(Distant::BaseTest.has_many?(:sub_tests)).to be_truthy
|
231
|
+
expect(Distant::BaseTest.new.has_many?(:sub_tests)).to be_truthy
|
232
232
|
end
|
233
233
|
end
|
234
234
|
context 'does not have many other_things' do
|
235
235
|
it 'returns false' do
|
236
|
-
expect(Distant::BaseTest.has_many?(:sdf987sd98f7)).to be_falsey
|
236
|
+
expect(Distant::BaseTest.new.has_many?(:sdf987sd98f7)).to be_falsey
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
@@ -243,12 +243,12 @@ describe Distant::Base do
|
|
243
243
|
context 'when the thing' do
|
244
244
|
context 'does belong to other_thing' do
|
245
245
|
it 'returns true' do
|
246
|
-
expect(Distant::SubTest.belongs_to?(:base_test)).to be_truthy
|
246
|
+
expect(Distant::SubTest.new.belongs_to?(:base_test)).to be_truthy
|
247
247
|
end
|
248
248
|
end
|
249
249
|
context 'does not have many other_things' do
|
250
250
|
it 'returns false' do
|
251
|
-
expect(Distant::SubTest.belongs_to?(:kjh234kjh23kj4h)).to be_falsey
|
251
|
+
expect(Distant::SubTest.new.belongs_to?(:kjh234kjh23kj4h)).to be_falsey
|
252
252
|
end
|
253
253
|
end
|
254
254
|
end
|