module_shims 0.2.0 → 0.2.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/lib/module_shims/switch.rb +11 -2
- data/lib/module_shims/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44ec366df9e0c8c7e9d7da1c46318c847e9b908c
|
4
|
+
data.tar.gz: 7ac110d834266c36c0b4c879cf5ab989f50c19bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2b2147aa19ea7d161fcd3865a6e2182ddf53c73725b2a3b4fe4e695fb481d44354ac992f6c4e566ec026f9b9ea01c5caf7df89512767ff25c7836f6bcf34d6
|
7
|
+
data.tar.gz: 9c36d93e6a865a9f4d69963b4506cd96f98cfc989f42a9e56d1fff7103634f4ddb1d424754c841ac00eec57584e239e04d6fddfd5493dd2dab4b28d527d21500
|
data/lib/module_shims/switch.rb
CHANGED
@@ -20,8 +20,17 @@ module ModuleShims
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def shim_const
|
23
|
-
|
24
|
-
|
23
|
+
return const_get('SHIM') if const_defined?('SHIM')
|
24
|
+
|
25
|
+
# use predefined_method to look up SHIM module. It's to support "reload!" in rails console
|
26
|
+
predefined_method = "#{self.name.downcase.gsub(/::/, '_')}_shim"
|
27
|
+
existing_shim = target_const.ancestors.find { |anc| anc.respond_to? predefined_method }
|
28
|
+
|
29
|
+
unless existing_shim
|
30
|
+
existing_shim = Module.new
|
31
|
+
existing_shim.singleton_class.send(:define_method, predefined_method) {}
|
32
|
+
end
|
33
|
+
const_set('SHIM', existing_shim)
|
25
34
|
end
|
26
35
|
|
27
36
|
def target_const
|
data/lib/module_shims/version.rb
CHANGED