interloper 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/interloper.rb +19 -1
- data/lib/interloper/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: 9a4c42296850197574e9584a94a4d5558b51a394
|
4
|
+
data.tar.gz: 231d3a66afb42b72dbdf095dfa408d59e9962fb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0e347bac1a8c4b796a4c44e191a8d45ad5f7bffa528a3f3bf39468b3ff05b59e6d185c31c0e3ea7f35d2fb148af5b1ab180a1488a9374b4898f167c2ff719fa
|
7
|
+
data.tar.gz: 3251971fd52654301b5d809a24388d812d12959b0ef14e2b45f7479887ce42f6519e3c40effd5a1d0a5686412ddd19cdc424f719d1d4508cd9fc04900f863d0e
|
data/lib/interloper.rb
CHANGED
@@ -26,13 +26,31 @@ module Interloper
|
|
26
26
|
# @return Module the Interloper module that was prepended to the including
|
27
27
|
# class.
|
28
28
|
def interloper_module
|
29
|
-
unless
|
29
|
+
unless prepended? interloper_const_name
|
30
30
|
const_set(interloper_const_name, generate_interloper_module)
|
31
31
|
prepend const_get(interloper_const_name)
|
32
32
|
end
|
33
33
|
const_get(interloper_const_name)
|
34
34
|
end
|
35
35
|
|
36
|
+
# @return Boolean True if the interloper module has already been prepnded;]
|
37
|
+
# false otherwise.
|
38
|
+
def prepended?(const_name)
|
39
|
+
if self.name
|
40
|
+
# If we are not anonymous, then check for the interloper constant name
|
41
|
+
# in the list of prepended modules.
|
42
|
+
prepended_modules.include? const_name
|
43
|
+
else
|
44
|
+
# If we are an anonymous class, check for the anonymous interloper
|
45
|
+
# module name in the list of constants defined for this class.
|
46
|
+
self.constants.include? interloper_const_name
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def prepended_modules
|
51
|
+
ancestors.slice(0, ancestors.find_index(self))
|
52
|
+
end
|
53
|
+
|
36
54
|
def generate_interloper_module
|
37
55
|
Module.new do
|
38
56
|
class << self
|
data/lib/interloper/version.rb
CHANGED