active_decorator 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31bd13919bc3d2af2331782394cad408aa5119c30a4bf6ccbed87dcb0399bd42
4
- data.tar.gz: bdcd4d4574bfcc06686deb960f4b91862ac805cf83d388c6485520d364143377
3
+ metadata.gz: 9a04b73afb4a350371ae29bcc036317ff6a4896fce57c701904e24e4344f0e58
4
+ data.tar.gz: af8d033bd3b0020126e130ff96c8d423679c1a098edf81b092c5be1ed531f79b
5
5
  SHA512:
6
- metadata.gz: 1c83e1c9d5d7d3477d1200032f6dada8afa10c37013891b7d574d5e9cba8c8845df1790f922615771f34ffe77c6e0d61853a12d18b5603b3342b5904d0004f2e
7
- data.tar.gz: b112eec94bd7634e9d41b4d2ef5e05e7c9479d727b010205a6f4dd2454be11734afdc03af1eacefa62b124ea418e272c22170336cb2f8d02b7b81a2cfb43b710
6
+ metadata.gz: c21ed89001953686a59cacae36ed644008fc0c0715135fa3810ce19e99d96863334ca8ca25d5236a5b1ec16a26adf0b5c993dc70f71357a80f002ce894899364
7
+ data.tar.gz: e82b20c35e83766a571edd74df0d0773ca962701bfcfb8dacf2b9faf7094e55336ce226446a33265b293b1e9841370760d6ccc67c2089243ef329718b03e5273
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.6.1
2
+
3
+ * Fixed a regression in 1.6.0 where decorating an object whose namespace forwards `const_missing` elsewhere (e.g. `URI::Generic`) raised NameError [#131, reported by @fanglang]
4
+
5
+
1
6
  ## 1.6.0
2
7
 
3
8
  * Don't swallow NameError raised from inside a decorator module while loading it. Previously such an error was silently rescued and the decorator just disappeared
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'singleton'
4
- require 'active_support/core_ext/name_error'
5
4
  require 'active_decorator/helpers'
6
5
  require 'active_decorator/decorated'
7
6
 
@@ -62,23 +61,22 @@ module ActiveDecorator
62
61
  return @decorators[model_class] if @decorators.key? model_class
63
62
 
64
63
  decorator_name = "#{model_class.name}#{ActiveDecorator.config.decorator_suffix}"
65
- d = decorator_name.constantize
66
- unless Class === d
67
- d.send :include, ActiveDecorator::Helpers
68
- @decorators[model_class] = d
69
- else
64
+ # safe_constantize returns nil when the decorator constant is missing, but re-raises
65
+ # NameErrors that were raised from inside the decorator module while loading it
66
+ d = decorator_name.safe_constantize
67
+ if d.nil?
68
+ if model_class.respond_to?(:base_class) && (model_class.base_class != model_class)
69
+ @decorators[model_class] = decorator_for model_class.base_class
70
+ else
71
+ # Cache nil results
72
+ @decorators[model_class] = nil
73
+ end
74
+ elsif Class === d
70
75
  # Cache nil results
71
76
  @decorators[model_class] = nil
72
- end
73
- rescue NameError => e
74
- # Re-raise NameErrors that were raised from inside the decorator module while loading it
75
- raise unless e.missing_name?(decorator_name)
76
-
77
- if model_class.respond_to?(:base_class) && (model_class.base_class != model_class)
78
- @decorators[model_class] = decorator_for model_class.base_class
79
77
  else
80
- # Cache nil results
81
- @decorators[model_class] = nil
78
+ d.send :include, ActiveDecorator::Helpers
79
+ @decorators[model_class] = d
82
80
  end
83
81
  end
84
82
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveDecorator
4
- VERSION = '1.6.0'
4
+ VERSION = '1.6.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda