wp-api 0.1.3 → 0.1.4

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: cb4a7bec44ae84c2ca08e6cb7dcb6f646c90f3aa
4
- data.tar.gz: dfe857f61cd26b4f2310415d0a53d1a97f59506d
3
+ metadata.gz: 014bb33ae92d9361bbd8d6a7459ace08504f29d3
4
+ data.tar.gz: 0b58919d93d5d0707daeba5a6b17284fd5bb0285
5
5
  SHA512:
6
- metadata.gz: 6001d3d7ebb517b4d79fa29de3c2ec3a28f9a613230cce957e35201534edbc49204c9510f495fa1f1f6aa4d6af6507a27e71c729b62b2c6a6106ee097fc7cc7b
7
- data.tar.gz: 853132092fe77cea5bf06004d2a6d8377fa3fa498d4459c01f9942331f99c00950adf2881c877029d5b87ab6ad93a034dd6ef0f04dccde04ce4e1188bb075826
6
+ metadata.gz: 32242ca52e07b44cc838066ab46cae8a9dbcbb073e539a04d999c32be2dd68f733f035aac659a71ad322ea1bd15e7dc8ef1ada6ce6020bfaac6b0c5f05ea8261
7
+ data.tar.gz: c3f076406ad24ab9e555201ce6374daa56c2a56cac06e450211dc9565acef676d93bd346bf6166f1c507e5c2a61cc99d98a9c9d77c107f15c51966033b76b0c7
@@ -28,6 +28,7 @@ module WP::API
28
28
  protected
29
29
 
30
30
  def get(resource, query = {})
31
+ should_raise_on_empty = query.delete(:should_raise_on_empty) || true
31
32
  query = ActiveSupport::HashWithIndifferentAccess.new(query)
32
33
  path = url_for(resource, query)
33
34
 
@@ -39,6 +40,8 @@ module WP::API
39
40
 
40
41
  if response.code != 200
41
42
  raise WP::API::ResourceNotFoundError
43
+ elsif response.parsed_response.empty? && should_raise_on_empty
44
+ raise WP::API::ResourceNotFoundError
42
45
  else
43
46
  [ response.parsed_response, response.headers ] # Already parsed.
44
47
  end
@@ -43,6 +43,7 @@ module WP::API
43
43
  end
44
44
 
45
45
  def resource_subpath(res, id, subpath, query = {})
46
+ query.merge(should_raise_on_empty: false)
46
47
  get("#{res}/#{id}/#{subpath}", query).first
47
48
  end
48
49
 
@@ -1,5 +1,5 @@
1
1
  module WP
2
2
  module API
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wp-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Young