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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/active_decorator/decorator.rb +13 -15
- data/lib/active_decorator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a04b73afb4a350371ae29bcc036317ff6a4896fce57c701904e24e4344f0e58
|
|
4
|
+
data.tar.gz: af8d033bd3b0020126e130ff96c8d423679c1a098edf81b092c5be1ed531f79b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
81
|
-
@decorators[model_class] =
|
|
78
|
+
d.send :include, ActiveDecorator::Helpers
|
|
79
|
+
@decorators[model_class] = d
|
|
82
80
|
end
|
|
83
81
|
end
|
|
84
82
|
|