interloper 0.1.6 → 0.2.0
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 +30 -0
- data/lib/interloper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc047e112f6e9d65787f70a15648c199831a0fad
|
4
|
+
data.tar.gz: d2b90ef44c9ed7dad1f50109f0b2a9285c904b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48abd48b4fe2fccb6950e8b09a01e9394c2ee902fc6162970214ed3b5fa2d14a367bafa92a0839b4e2231c931759b48d087926a21fd3b43859cd07f6dc940d5c
|
7
|
+
data.tar.gz: a624029a8a861f5dc6287b4b74712f69ad2c11d7f43524c401293dd3ac148441ec530d7eca7e1fa824dbb1a0448e57e0e6a4ab176c24562383055a2eeb893010
|
data/lib/interloper.rb
CHANGED
@@ -114,5 +114,35 @@ module Interloper
|
|
114
114
|
interloper_module.define_interloper_methods(*method_names, interloper_const_name)
|
115
115
|
interloper_module.add_callbacks(:after, *method_names, &callback)
|
116
116
|
end
|
117
|
+
|
118
|
+
def inherit_callbacks_for(*method_names)
|
119
|
+
inherit_callbacks_before(*method_names)
|
120
|
+
inherit_callbacks_after(*method_names)
|
121
|
+
end
|
122
|
+
|
123
|
+
def inherit_callbacks_before(*method_names)
|
124
|
+
inherited_callbacks(:before, *method_names).each do |callback|
|
125
|
+
before(*method_names, &callback)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def inherit_callbacks_after(*method_names)
|
130
|
+
inherited_callbacks(:after, *method_names).each do |callback|
|
131
|
+
after(*method_names, &callback)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def inherited_callbacks(hook, *method_names)
|
136
|
+
method_names.map do |method_name|
|
137
|
+
ancestor_interloper_module.callbacks[hook][method_name]
|
138
|
+
end.flatten
|
139
|
+
end
|
140
|
+
|
141
|
+
# @return [Module] The nearest ancstors tha is an interloper module.
|
142
|
+
def ancestor_interloper_module
|
143
|
+
ancestors.detect do |ancestor|
|
144
|
+
ancestor.respond_to?(:interloper_module) && (ancestor != self)
|
145
|
+
end.interloper_module
|
146
|
+
end
|
117
147
|
end
|
118
148
|
end
|
data/lib/interloper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interloper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Myers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|