interloper 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a9c3a3bb7170e182c88f37908571d52f165a80
4
- data.tar.gz: 86a0dc4040a0aba7469f3e51c505de661ea50645
3
+ metadata.gz: bc047e112f6e9d65787f70a15648c199831a0fad
4
+ data.tar.gz: d2b90ef44c9ed7dad1f50109f0b2a9285c904b84
5
5
  SHA512:
6
- metadata.gz: be7663d189f1c0c5eda5e1f7df60f0b1af97518b8300a725c56efe6bf59af0510096dc82af0f3c674439dc802d30fe96003011b837b5991336db0eec350d20ff
7
- data.tar.gz: 703cc70fb95866cd57b5f9aa8e489afcc1ef5558d4580b84872f6bf4c20463058022f35be61ea5a94c39c6e8d27b047f680f9004ed22cf44229b35d146cd9a51
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
@@ -1,3 +1,3 @@
1
1
  module Interloper
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.6
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-03 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler