hal_api-rails 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: 35f7ab8e051a6d7132ecf26800670c4e56489c7371539ac92fdcc6e88fb5d280
4
- data.tar.gz: 5fd5ecbdd0ba0287c0c01e1e5ed24cd23b5cb10aa157be28224b7ec6c6c25698
3
+ metadata.gz: 93692b389012f8d919478bd871f756f90118c517a1edde2a5ae6cbb463d644b1
4
+ data.tar.gz: b15713d0ba0c1e005044dc48cc0a737066d89e1de84f1233e8072e17cdabc6d6
5
5
  SHA512:
6
- metadata.gz: 653ca1b7461fd1c3b598904e85e430c4632485f6c390192deaab63dc8e0a13c3970ed4d94486d1cf749d09966edf4055602b00a71e3f54c7b83a08bdc21a57b2
7
- data.tar.gz: 11ce89bb941bf1e9f83d377fe1bc7b0da9a6e94cd7d7e93fb8b516348ceb7550e37966c2cbb6b4357f90bed927130a5a44658de12572ac0a37e1a2f270890f05
6
+ metadata.gz: 572d57798b5240e8e33032de9b74492548f4901bb3fc74e9f2c40b65c59fea32d59b51a958e62087609365302ceb6fc349532920fb779a9d3d35aab841e97be5
7
+ data.tar.gz: 8f2e81fe36e137287dab3492dc0636588c06ba3910fe9ddb682e3bfe42ddede2c4e79717229f12a6af8174bbde2fcf1cb222fbdc5aaadc1d64807f0c12e7e175
@@ -25,11 +25,12 @@ module HalApi::Controller::Exceptions
25
25
 
26
26
  notice_error(exception) if error.status >= 500
27
27
 
28
- json = {status: error.status, message: error.message}
29
- if Rails.configuration.try(:consider_all_requests_local)
30
- json[:backtrace] = error.backtrace
31
- end
32
- render status: error.status, json: json
28
+ respond_with(
29
+ error,
30
+ status: error.status,
31
+ location: nil, # for POST requests
32
+ represent_with: HalApi::Errors::Representer
33
+ )
33
34
  end
34
35
 
35
36
  def log_error(env, wrapper)
@@ -48,4 +48,12 @@ module HalApi::Errors
48
48
  super(msg, 400, hint)
49
49
  end
50
50
  end
51
+
52
+ module Representer
53
+ include Roar::JSON::HAL
54
+
55
+ property :status
56
+ property :message
57
+ property :backtrace, if: -> (*) { Rails.configuration.try(:consider_all_requests_local) }
58
+ end
51
59
  end
@@ -1,5 +1,5 @@
1
1
  module HalApi
2
2
  module Rails
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -41,6 +41,9 @@ module HalApi::Representer::Embeds
41
41
 
42
42
  binding = options[:binding]
43
43
 
44
+ # guard against non-hal representers
45
+ return false unless binding[:as].present?
46
+
44
47
  name = binding.evaluate_option(:as, input, options)
45
48
 
46
49
  embedded = binding[:embedded]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hal_api-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Rhoden