escalate 0.2.0.pre.1 → 0.2.0.pre.2

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: 2a0dc76f8fb9f09d141c117b3b746b143078712c8d14687e9a413f9e0db0eee4
4
- data.tar.gz: 0a8861399988e40db304ff5bed43a5a3c6359eb2f0853f162515c5883e74c613
3
+ metadata.gz: 8e6dc6ba580b590c324c351001687805582d7a2d757cb7aebeaed1a6ee50d07b
4
+ data.tar.gz: '02439935ba7a19a8c68b5ff0adcad892d658b29a2f843311a79a798fa090fac2'
5
5
  SHA512:
6
- metadata.gz: 95f0fd83333e4245756cee9c5fff725255a8b81e954102ad22e8d0d2c0f49bf27050c15154a00a309d4c0bce8f9edd7e5247aba3dfdc8b2f9b1fa64cbf281ab8
7
- data.tar.gz: 62f87cc4801ff0a5187c251ec2fe0e47433d52ab4bdc89558af29a57f6bbf50ee912c9e92127c4a152a5008cf1d7e3110735b8082ec540b6aac9e7d95bf2fa18
6
+ metadata.gz: 39d9cb26ed59b9eca7f0a234ed2ead5375ae2144128098b6cd74bbabe54cdd6281278baaf12cf186a4873c9bf50092f5440e4e10931da33f606bca344f76edd6
7
+ data.tar.gz: d9608ff9899f52a7a99a2e26937340b3909d4715e9f5dbd68bdb7474fbe2782c7419f277ef3ab3d21d931a4fa9ad656b877929796707003fb01b771e8910370f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- escalate (0.2.0.pre.1)
4
+ escalate (0.2.0.pre.2)
5
5
  activesupport
6
6
 
7
7
  GEM
data/lib/escalate.rb CHANGED
@@ -9,6 +9,8 @@ require_relative "escalate/mixin"
9
9
  module Escalate
10
10
  class Error < StandardError; end
11
11
 
12
+ LOG_FIRST_INSTANCE_VARIABLE = :@_escalate_log_first
13
+
12
14
  class << self
13
15
  # Logs and escalated an exception
14
16
  #
@@ -25,7 +27,7 @@ module Escalate
25
27
  # Any additional context to be tied to the escalation
26
28
  def escalate(exception, location_message, logger, **context)
27
29
  ensure_failsafe("Exception rescued while escalating #{exception.inspect}") do
28
- if on_escalate_blocks.any? || on_escalate_no_log_first_blocks.none?
30
+ if on_escalate_blocks.none? || on_escalate_blocks.any? { |block| block.instance_variable_get(LOG_FIRST_INSTANCE_VARIABLE) }
29
31
  error_message = <<~EOS
30
32
  [Escalate] #{location_message} (#{context.inspect})
31
33
  #{exception.class.name}: #{exception.message}
@@ -39,7 +41,7 @@ module Escalate
39
41
  end
40
42
  end
41
43
 
42
- all_on_escalate_blocks.each do |block|
44
+ on_escalate_blocks.each do |block|
43
45
  ensure_failsafe("Exception rescued while escalating #{exception.inspect} to #{block.inspect}") do
44
46
  block.call(exception, location_message, **context)
45
47
  end
@@ -87,16 +89,12 @@ module Escalate
87
89
  # @param [boolean] log_first: true
88
90
  # whether escalate should log first before escalating, or leave the logging to the escalate block
89
91
  def on_escalate(log_first: true, &block)
90
- if log_first
91
- on_escalate_blocks.add(block)
92
- else
93
- on_escalate_no_log_first_blocks.add(block)
94
- end
92
+ block.instance_variable_set(LOG_FIRST_INSTANCE_VARIABLE, log_first)
93
+ on_escalate_blocks.add(block)
95
94
  end
96
95
 
97
- def clear_all_on_escalate_blocks
96
+ def clear_on_escalate_callbacks
98
97
  on_escalate_blocks.clear
99
- on_escalate_no_log_first_blocks.clear
100
98
  end
101
99
 
102
100
  private
@@ -115,13 +113,5 @@ module Escalate
115
113
  def on_escalate_blocks
116
114
  @on_escalate_blocks ||= Set.new
117
115
  end
118
-
119
- def on_escalate_no_log_first_blocks
120
- @on_escalate_no_log_first_blocks ||= Set.new
121
- end
122
-
123
- def all_on_escalate_blocks
124
- on_escalate_blocks + on_escalate_no_log_first_blocks
125
- end
126
116
  end
127
117
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Escalate
4
- VERSION = "0.2.0.pre.1"
4
+ VERSION = "0.2.0.pre.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escalate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre.1
4
+ version: 0.2.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development