bookingsync-api 0.0.14 → 0.0.15

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: 880e050165fd6662866b2727aa066a6df376a609
4
- data.tar.gz: bb7c1426aab6968106fae175fca59d8a4faa95bb
3
+ metadata.gz: 0c227ffca57d5a71ca428eb080f31d9394886a8c
4
+ data.tar.gz: 1a2091bf8a21644e083c5e2477e6f43a8103cedb
5
5
  SHA512:
6
- metadata.gz: afaf6373157977f8af580f7d360761b440d54e53a1a08426ea267971bc27ca378730f31a6eaacf2c2cdb5a98954f9a0ec24d7e95d4bc2548bc3c0917c09d7b4b
7
- data.tar.gz: eddb23e23bb4c566592c60553287ed47329fbe054ab7c1e065f519a31dabc6a4d490dc19af973153465a354aef9e596f29831416c544fc7b425e61f0ccf9a0e1
6
+ metadata.gz: 02414dbb6763973ae82d61818d09e0b0cb34716c9d76dfebf9c56ce979401113a6d451f63636ba4d4a3cdc5f4b65810e729b97eb1d497aa909e62219b0722597
7
+ data.tar.gz: 72a59fd4a42a566171750bdb2186f64684da910cf57bb1d7b97b01a8e0d084ebf0bc22e72b16a11d217c5e640bdcf9eaee1439e808b35633ec65e880da6f5e3e
@@ -38,6 +38,7 @@ module BookingSync::API
38
38
  # @param method [Symbol] Name of association
39
39
  # @param args [Array] Array of additional arguments
40
40
  def method_missing(method, *args)
41
+ return self[method] if has_key?(method) # eager loaded with :include
41
42
  association_key = :"#{@_resources_key}.#{method}"
42
43
  if self[:links] && self[:links].has_key?(method)
43
44
  ids = Array(self[:links][method])
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.0.14"
3
+ VERSION = "0.0.15"
4
4
  end
5
5
  end
@@ -2,22 +2,22 @@ require 'spec_helper'
2
2
 
3
3
  describe BookingSync::API::Resource do
4
4
  let(:links) { {photos: [9, 10]} }
5
+ let(:relation) {
6
+ BookingSync::API::Relation.from_links(client, {
7
+ :"foo.photos" => "http://foo.com/photos/{foo.photos}",
8
+ :"foo.category" => "http://foo.com/categories/{foo.category}"
9
+ })
10
+ }
11
+ let(:client) { BookingSync::API::Client.new(test_access_token,
12
+ base_url: "http://foo.com") }
13
+ let(:data) { {
14
+ name: "foo", width: 700,
15
+ links: links,
16
+ details: {count: 1},
17
+ id: 10
18
+ } }
5
19
  let(:resource) {
6
- client = BookingSync::API::Client.new(test_access_token,
7
- base_url: "http://foo.com")
8
- BookingSync::API::Resource.new(client,
9
- {
10
- name: "foo", width: 700,
11
- links: links,
12
- details: {count: 1},
13
- id: 10
14
- },
15
- BookingSync::API::Relation.from_links(client, {
16
- :"foo.photos" => "http://foo.com/photos/{foo.photos}",
17
- :"foo.category" => "http://foo.com/categories/{foo.category}"
18
- }),
19
- "foo"
20
- )
20
+ BookingSync::API::Resource.new(client, data, relation, "foo")
21
21
  }
22
22
 
23
23
  describe "processing values" do
@@ -81,6 +81,19 @@ describe BookingSync::API::Resource do
81
81
  .to_return(body: {photos: [{file: 'a.jpg'}]}.to_json)
82
82
  resource.photos(fields: :description)
83
83
  end
84
+
85
+ context "when association loaded by eager loading" do
86
+ let(:data) { {links: links, photos: [{file: 'b.jpg'}]} }
87
+
88
+ it "doesn't fetch it again" do
89
+ resource.photos
90
+ assert_not_requested :get, "http://foo.com/photos/9,10"
91
+ end
92
+
93
+ it "returns previously loaded data" do
94
+ expect(resource.photos).to eq([{file: 'b.jpg'}])
95
+ end
96
+ end
84
97
  end
85
98
 
86
99
  describe "#to_s" do
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookingsync-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Grosjean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: This gem allows to interact with the BookingSync API via Ruby objects
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .rspec
92
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
93
  - Gemfile
94
94
  - Guardfile
95
95
  - LICENSE.txt
@@ -233,17 +233,17 @@ require_paths:
233
233
  - lib
234
234
  required_ruby_version: !ruby/object:Gem::Requirement
235
235
  requirements:
236
- - - '>='
236
+ - - ">="
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - '>='
241
+ - - ">="
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project:
246
- rubygems_version: 2.0.14
246
+ rubygems_version: 2.2.2
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: Ruby interface for accessing https://www.bookingsync.com