enhanced_errors 2.0.2 → 2.0.3

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: 70b9bd7350206b35123f8475f484f039214a2ce13003fbd1c94988e7aa1d0c84
4
- data.tar.gz: 57f683a995c2347284943370445ae0d6a32c6e1e15457cbd82758e67bbd1567d
3
+ metadata.gz: 9e2de1d0aba8d7c6c9d2749315f47f06f78c512adefb7aa4177cf42943823827
4
+ data.tar.gz: 9afab2c281e0d7ef2e1e36c3329446f0b2fec46fa1534c3f562ca6f18bf465f2
5
5
  SHA512:
6
- metadata.gz: 34c46fe729c5e7c8b28a15a174c7175502df28949eb079344582582a5b7c26203f052aab55e05e4197a12b084de82a93017dfb01fdd3f7dfae7cec846b5ad127
7
- data.tar.gz: 0cb2a347a54e18538f6dbb26c596d3b20e50bfd2b1cbd67c2eff9c0a64ac5297cef2276c2453e9ed4668f44ddc7f2ce1613894c84c0d726654dc2354bdf46a42
6
+ metadata.gz: 6b500dc5833a15bb7e40998ba6574ae5c2cc1dda5f58c57f020cc3b30bd61d4d174b86744bcca5bde0146183ab5ad7693a4df8dabd863a7eea48b6f23ed5f29d
7
+ data.tar.gz: ed1841c47b7eea81e7fda7d462b47f15b9f10426a0224601551a81c18cbb88ff1cf0a0a60ea073d9f83e9e0df2d174bf2c4f90608d39574b9afe1fa359d5f69d
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "enhanced_errors"
3
- spec.version = "2.0.2"
3
+ spec.version = "2.0.3"
4
4
  spec.authors = ["Eric Beland"]
5
5
 
6
6
  spec.summary = "Automatically enhance your errors with messages containing variable values from the moment they were raised."
@@ -580,17 +580,29 @@ class EnhancedErrors
580
580
  end
581
581
 
582
582
  def determine_object_name(tp, method_name = '')
583
- if tp.self&.is_a?(Class) && tp.self&.singleton_class == tp.defined_class
584
- object_identifier = safe_to_s(tp.self)
585
- method_suffix = method_name && !method_name.empty? ? ".#{method_name}" : ""
586
- "#{object_identifier}#{method_suffix}"
587
- else
588
- object_class_name = safe_to_s(tp.self&.class&.name || 'UnknownClass')
589
- method_suffix = method_name && !method_name.empty? ? "##{method_name}" : ""
590
- "#{object_class_name}#{method_suffix}"
583
+ begin
584
+ # These tricks are used to get around the fact that `tp.self` can be a class that is
585
+ # wired up with method_missing where every direct call alters the class. This is true
586
+ # on certain builders or config objects and caused problems.
587
+
588
+ # Directly bind and call the `class` method to avoid triggering `method_missing`
589
+ self_class = Object.instance_method(:class).bind(tp.self).call
590
+
591
+ # Similarly, bind and call `singleton_class` safely
592
+ singleton_class = Object.instance_method(:singleton_class).bind(tp.self).call
593
+
594
+ if self_class && tp.defined_class == singleton_class
595
+ object_identifier = safe_to_s(tp.self)
596
+ method_suffix = method_name && !method_name.empty? ? ".#{method_name}" : ""
597
+ "#{object_identifier}#{method_suffix}"
598
+ else
599
+ object_class_name = safe_to_s(self_class.name || 'UnknownClass')
600
+ method_suffix = method_name && !method_name.empty? ? "##{method_name}" : ""
601
+ "#{object_class_name}#{method_suffix}"
602
+ end
603
+ rescue Exception => e
604
+ '[ErrorGettingName]'
591
605
  end
592
- rescue Exception => e
593
- '[ErrorGettingName]'
594
606
  end
595
607
 
596
608
  def get_global_variable_value(var)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Beland