json_api_model 0.3.2 → 0.4.0

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: b6f8100a1075e901d8733ccea171cb0fa211de66
4
- data.tar.gz: d1fa53d8997a473bd2efc1b83b8e9cf65fdef14b
3
+ metadata.gz: 0dcc8c7cf054ebbc3e13ff7f11e526703d8763fd
4
+ data.tar.gz: d11d0c76be9f5f0e7ff0b9545731e0534c66485c
5
5
  SHA512:
6
- metadata.gz: 8eef7df9cc3053feaa2600a7b38a87fdb17d6f1a8a3df89e8ed8390470cff0f8479422e328e91a29948fc7ffc4befc3a36371a4518a20b2afd75675f97df5316
7
- data.tar.gz: 8228712a1522f1d91bf3771b0afa41895dae137095541b45cbbe31a9f8c1fdac4773ccaa187dce137176ff1e9f2ffbfacddfa668a39457165c09a529345521bb
6
+ metadata.gz: 6d6330ad95f23f9e0e3d97945f00d26f37c0a9d6f79598fba478b901a477718ce1c771121fe96b54c21d7510b8092a98cd0f817bddda3b527bae518449c9c38a
7
+ data.tar.gz: 55d212fb0693ae234aebc7cfd51c0e7e4f85d7cafd6a860261be22f2c26e8e1ca1f286aa733d03eeaae36c9974de4149c6ffdeae6f82aad55ae40b6ab46f552d
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec
3
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_api_model (0.3.2)
4
+ json_api_model (0.4.0)
5
5
  activesupport
6
6
  json_api_client
7
7
 
@@ -29,15 +29,15 @@ GEM
29
29
  i18n (1.1.0)
30
30
  concurrent-ruby (~> 1.0)
31
31
  json (2.1.0)
32
- json_api_client (1.5.3)
32
+ json_api_client (1.6.0)
33
33
  activemodel (>= 3.2.0)
34
34
  activesupport (>= 3.2.0)
35
35
  addressable (~> 2.2)
36
- faraday (~> 0.9)
36
+ faraday (~> 0.15, >= 0.15.2)
37
37
  faraday_middleware (~> 0.9)
38
38
  minitest (5.11.3)
39
39
  multipart-post (2.0.0)
40
- public_suffix (3.0.2)
40
+ public_suffix (3.0.3)
41
41
  rake (10.5.0)
42
42
  safe_yaml (1.0.4)
43
43
  simplecov (0.16.1)
@@ -13,7 +13,7 @@ module JsonApiModel
13
13
 
14
14
  def query( instance )
15
15
  if instance.has_relationship_ids? name
16
- { id: instance.relationship_ids( name ) }
16
+ instance.relationship_ids( name ).first
17
17
  else
18
18
  instance.send key
19
19
  end
@@ -42,21 +42,25 @@ module JsonApiModel
42
42
  end
43
43
  end
44
44
 
45
- def params
46
- @client_scope.params
47
- end
48
-
49
45
  def method_missing( m, *args, &block )
50
46
  if @client_scope.respond_to? m
51
- @client_scope.send m, *args, &block
52
- self
47
+ _new_scope @client_scope.send( m, *args, &block )
53
48
  else
54
49
  all.send m, *args, &block
55
50
  end
56
51
  end
57
52
 
53
+ attr_accessor :client_scope
54
+ delegate :params, to: :client_scope
55
+
58
56
  private
59
57
 
58
+ def _new_scope( client_scope )
59
+ self.class.new( @model_class ).tap do |scope|
60
+ scope.client_scope = client_scope
61
+ end
62
+ end
63
+
60
64
  def cached?
61
65
  @cache.has_key? keyify
62
66
  end
@@ -1,3 +1,3 @@
1
1
  module JsonApiModel
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Orlov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-24 00:00:00.000000000 Z
11
+ date: 2018-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport