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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26713c61cff1da17cdee7e0eb0b26cfa735aa2ec
4
- data.tar.gz: 699ec5c4908a19d80dba0f9c84226ce02e2208e8
3
+ metadata.gz: 04f23a0783899b668d29d4c7d9b69094bba82ab7
4
+ data.tar.gz: c4ec21cd7156223d2913e623c02beb75acc3260d
5
5
  SHA512:
6
- metadata.gz: 278282dcb599fc56884c04b9b10782f65615813fd5dee3726d2a277b589cffc887e499718f9b5ad74cf7c8c0225a682c6ecbf8cd418de6be614a7e72f0afed73
7
- data.tar.gz: df11c199e6bf8de859cbb3fe585c949e390aa486cc8c13d90ed9efb1a84df385265142473ae4a164df1ba9cbf4796be198b263b0439dd88355cd6bf8763624d0
6
+ metadata.gz: 8814fe8479e43c40afc77f87cf26f7d12531ccad28b0ff1d501a67ac2b203d25e7f4ef0a623adb68199235f606aafafb8d98e4723c57dbccbc16da29d06082a1
7
+ data.tar.gz: 2f74f38442f84652a3589284daff9caf43545ddf70075960a09f7da3de347f5b88ba5b8357da2d62e8c356946d54f5380133910892e293df53609df450423fc1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- distant (0.1.1)
4
+ distant (0.1.3)
5
5
  activesupport
6
6
  httparty
7
7
 
data/distant.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'distant'
3
- spec.version = '0.1.2'
3
+ spec.version = '0.1.3'
4
4
  spec.authors = ['John Drago']
5
5
  spec.email = 'jdrago.999@gmail.com'
6
6
  spec.homepage = 'https://github.com/distant/distant'
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Drago