jsonapionify 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGMzNzNlNDJhYmZjNmI2Njk3MzZjNzQ0ZDI3OTk1N2YwZjJjMGRlMg==
4
+ OTZmYTcyMjIzZGQ1YTcyZGI5M2E4MzM2YmRmNDFlM2FhMjJjMjlmYg==
5
5
  data.tar.gz: !binary |-
6
- MTdlNzYwNDFmYjBjNWMzNjA3YmZjNzA3MDIwZGE2ZTAzMjc4ZDNhMw==
6
+ ZGQxMmU3MDlhMzQyNTRkMzg3ZWNlM2Q3MDFiNjNmNGM4YTRjMzM1Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzdiZTQyOGE5NDI4ZmNlYTA2NTNlZDY1M2ViOTQyMGQwMDVjYjNmMmYxYTY4
10
- NGMyODcyOGYxNzgwMWY3NWViOWUzYjk5NWMwNzZkMGMzMzlmNTMwNmFiMTlk
11
- MWJjOGI3MTQwOTI0NTM5MGI2ZjBiOWNjYWRiZWUyZTU1MDczYzM=
9
+ ZjI4YTZkZTQxM2VmZTU3NWU2NTNlYmY3OGQ2YjYyOTdlNjU2NmMxZTk3YmI0
10
+ ODU1YjA5MjE5NjQ0NTc3MzcwOWYyMzJjOWYyNGExYWRkMjkyZGYzNWRlODcx
11
+ NmYwNGNmYTM2MTU2YzY2M2UyNjQyYmNiYzU3MWRhMzFhMmFhYzY=
12
12
  data.tar.gz: !binary |-
13
- Y2U0NGU1OWZhZWNhMDIxODg5ZjU4NWM3OTkyYTkzNjM5NzE2OGNiZTZjMTA4
14
- YWFkMTVjZGNjZGNjZDY2YTQ1NzhkZjE2OTdiNDAxODI2ZjEzZGRlN2ZkYzUy
15
- MmI4YWYzOWI2NjhhZjMwZDhiYmM0ZWUwYzAxYTQ5Zjk0YTc2YzY=
13
+ MmE5MzlkOWZjOTg5NzlmNGM0ZDFiYzFlZmVjNTQzZGJkYjAwYWMzN2JiMjhi
14
+ ZTkzNTMxNWE5ZGI2NzcxNWY0ZTc3ZjMxNTdjN2ZmNjQ0NmYwOGJhMjYwZTc2
15
+ NmQ2ZGYzZjAxMzRiNDlmOGMxMjdmMDE0NzNiYmUzNzAzODNjMTk=
@@ -13,7 +13,7 @@ module JSONAPIonify::Api
13
13
  rescue Exception => exception
14
14
  response = rescued_response exception, @__context, do_respond
15
15
  ensure
16
- self.class.cache_store.delete @cache_options[:key] unless response[0] < 300
16
+ self.class.cache_store.delete @cache_options[:key] unless !response || response[0] < 300
17
17
  end
18
18
 
19
19
  def response_definition
@@ -10,13 +10,13 @@ module JSONAPIonify::Api
10
10
  context(:errors, readonly: true, persisted: true) do
11
11
  ErrorsObject.new
12
12
  end
13
- register_exception Exception, error: :internal_server_error do |exception|
13
+ register_exception Exception, error: :internal_server_error, callbacks: true do |exception|
14
14
  if JSONAPIonify.verbose_errors
15
15
  detail exception.message
16
16
  meta[:error_class] = exception.class.name
17
17
  end
18
18
  end
19
- register_exception Errors::RequestError, error: :internal_server_error do |exception|
19
+ register_exception Errors::RequestError, error: :internal_server_error, callbacks: true do |exception|
20
20
  if JSONAPIonify.verbose_errors
21
21
  detail exception.message
22
22
  meta[:error_class] = exception.class.name
@@ -30,14 +30,21 @@ module JSONAPIonify::Api
30
30
  self.error_definitions = self.error_definitions.merge name.to_sym => block
31
31
  end
32
32
 
33
- def register_exception(*klasses, error:, &block)
33
+ def register_exception(*klasses, callbacks: false, error:, &block)
34
34
  block ||= proc {}
35
35
  rescue_from(*klasses) do |exception, context|
36
- errors.evaluate(
37
- error_block: lookup_error(error),
38
- runtime_block: proc { instance_exec exception, context, &block },
39
- backtrace: exception.backtrace
40
- )
36
+ evaluate = proc {
37
+ errors.evaluate(
38
+ error_block: lookup_error(error),
39
+ runtime_block: proc { instance_exec exception, context, &block },
40
+ backtrace: exception.backtrace
41
+ )
42
+ }
43
+ if callbacks
44
+ run_callbacks :exception, exception, &evaluate
45
+ else
46
+ evaluate.call
47
+ end
41
48
  end
42
49
  end
43
50
 
@@ -1,3 +1,3 @@
1
1
  module JSONAPIonify
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapionify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Waldrip