no_backsies 0.3.0 → 0.3.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.
- data/HISTORY.rdoc +7 -1
- data/QED.rdoc +383 -0
- data/README.rdoc +1 -1
- data/lib/no_backsies.rb +6 -6
- data/qed/callbacks/01_method_added.rdoc +23 -0
- data/qed/callbacks/02_method_removed.rdoc +26 -0
- data/qed/callbacks/03_method_undefined.rdoc +26 -0
- data/qed/callbacks/04_singleton_method_added.rdoc +23 -0
- data/qed/callbacks/05_singleton_method_removed.rdoc +28 -0
- data/qed/callbacks/06_singleton_method_undefined.rdoc +24 -0
- data/qed/callbacks/07_const_missing.rdoc +24 -0
- data/qed/callbacks/08_included.rdoc +28 -0
- data/qed/callbacks/09_extended.rdoc +28 -0
- data/qed/callbacks/10_inherited.rdoc +22 -0
- metadata +14 -3
data/HISTORY.rdoc
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
== 0.3.0 | 2011-07-06
|
4
4
|
|
5
|
-
|
5
|
+
This release is made primarily because the program is now
|
6
|
+
distributed under the BSD 2-Clause license.
|
7
|
+
|
8
|
+
Changes:
|
9
|
+
|
10
|
+
* Changed licenses to BSD 2-Clause.
|
11
|
+
* Cleaned up project files.
|
6
12
|
|
7
13
|
|
8
14
|
== 0.2.0 | 2011-04-29 (Later on Wedding Day)
|
data/QED.rdoc
ADDED
@@ -0,0 +1,383 @@
|
|
1
|
+
= Basic Example
|
2
|
+
|
3
|
+
First require the NoBacksies library.
|
4
|
+
|
5
|
+
require 'no_backsies'
|
6
|
+
|
7
|
+
Include the Callbacks module in a class and define
|
8
|
+
a callback procedure.
|
9
|
+
|
10
|
+
class Y
|
11
|
+
include NoBacksies::Callbacks
|
12
|
+
|
13
|
+
def self.list
|
14
|
+
@list ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
callback :method_added do |method|
|
18
|
+
list << method
|
19
|
+
end
|
20
|
+
|
21
|
+
def foo; end
|
22
|
+
def bar; end
|
23
|
+
end
|
24
|
+
|
25
|
+
We can see that +list+ holds the methods added.
|
26
|
+
|
27
|
+
Y.list.assert == [:foo, :bar]
|
28
|
+
|
29
|
+
|
30
|
+
= Callback Expression
|
31
|
+
|
32
|
+
NoBacksies makes it easier to control callback expression. This
|
33
|
+
is useful in the prevention of infinite recursion. For instance,
|
34
|
+
infinite recursion is a common problem when a +method_added+ callback
|
35
|
+
defines a new method.
|
36
|
+
|
37
|
+
Here is an example that demonstrates how to work around this problem
|
38
|
+
using the +callback_express+ method.
|
39
|
+
|
40
|
+
class Z
|
41
|
+
include NoBacksies::Callbacks
|
42
|
+
|
43
|
+
callback :method_added do |method|
|
44
|
+
callback_express :method_added=>false do
|
45
|
+
define_method("#{method}!") do
|
46
|
+
send(method) + "!"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def foo; "foo"; end
|
52
|
+
def bar; "bar"; end
|
53
|
+
end
|
54
|
+
|
55
|
+
In this example, a new `Z` object will get an automatically defined bang method
|
56
|
+
for every explicitly defined method.
|
57
|
+
|
58
|
+
z = Z.new
|
59
|
+
z.foo #=> "foo"
|
60
|
+
z.foo! #=> "foo!"
|
61
|
+
z.bar #=> "bar"
|
62
|
+
z.bar! #=> "bar!"
|
63
|
+
|
64
|
+
|
65
|
+
= Callback Options
|
66
|
+
|
67
|
+
== Once Callback Option
|
68
|
+
|
69
|
+
NoBacksies supports special callback options. The first is +:once+.
|
70
|
+
By setting +:once+ to +true+, the callback will be used one time and
|
71
|
+
then removed.
|
72
|
+
|
73
|
+
class Q
|
74
|
+
include NoBacksies::Callbacks
|
75
|
+
|
76
|
+
def self.list
|
77
|
+
@list ||= []
|
78
|
+
end
|
79
|
+
|
80
|
+
callback :method_added, :once=>true do |method|
|
81
|
+
list << method
|
82
|
+
end
|
83
|
+
|
84
|
+
def foo; "foo"; end
|
85
|
+
def bar; "bar"; end
|
86
|
+
end
|
87
|
+
|
88
|
+
Here we see that only :foo has been added to the list.
|
89
|
+
|
90
|
+
Q.list #=> [:foo]
|
91
|
+
|
92
|
+
== Safe Callback Option
|
93
|
+
|
94
|
+
The other option supported is +:safe+. When +:safe+ is set to true
|
95
|
+
the callback is automatically wrapped in an #callback_express block
|
96
|
+
that sets the expression of the callback to false while it is being
|
97
|
+
processed. This means we can rewrite our first example more succinctly.
|
98
|
+
|
99
|
+
class Z2
|
100
|
+
include NoBacksies::Callbacks
|
101
|
+
|
102
|
+
callback :method_added, :safe=>true do |method|
|
103
|
+
define_method("#{method}!") do
|
104
|
+
send(method) + "!"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def foo; "foo"; end
|
109
|
+
def bar; "bar"; end
|
110
|
+
end
|
111
|
+
|
112
|
+
In this example, a new `Z` object will get an automatically defined bang method
|
113
|
+
for every explicitly defined method.
|
114
|
+
|
115
|
+
z = Z2.new
|
116
|
+
z.foo #=> "foo"
|
117
|
+
z.foo! #=> "foo!"
|
118
|
+
z.bar #=> "bar"
|
119
|
+
z.bar! #=> "bar!"
|
120
|
+
|
121
|
+
|
122
|
+
== Method Added
|
123
|
+
|
124
|
+
Given a class that defines a no-backsies +method_added+ callback.
|
125
|
+
|
126
|
+
class Y
|
127
|
+
include NoBacksies::Callbacks
|
128
|
+
|
129
|
+
def self.list
|
130
|
+
@list ||= []
|
131
|
+
end
|
132
|
+
|
133
|
+
callback :method_added do |method|
|
134
|
+
list << method
|
135
|
+
end
|
136
|
+
|
137
|
+
def foo; end
|
138
|
+
def bar; end
|
139
|
+
end
|
140
|
+
|
141
|
+
Then the results are as follows.
|
142
|
+
|
143
|
+
Y.list #=> [:foo, :bar]
|
144
|
+
|
145
|
+
|
146
|
+
== Method Removed
|
147
|
+
|
148
|
+
Given a class that defines a no-backsies +method_removed+ callback.
|
149
|
+
|
150
|
+
class Y
|
151
|
+
include NoBacksies::Callbacks
|
152
|
+
|
153
|
+
def self.list
|
154
|
+
@list ||= []
|
155
|
+
end
|
156
|
+
|
157
|
+
callback :method_removed do |method|
|
158
|
+
list << method
|
159
|
+
end
|
160
|
+
|
161
|
+
def foo; end
|
162
|
+
def bar; end
|
163
|
+
|
164
|
+
remove_method(:foo)
|
165
|
+
remove_method(:bar)
|
166
|
+
end
|
167
|
+
|
168
|
+
Then the results are as follows.
|
169
|
+
|
170
|
+
Y.list #=> [:foo, :bar]
|
171
|
+
|
172
|
+
|
173
|
+
== Method Undefined
|
174
|
+
|
175
|
+
Given a class that defines a no-backsies +method_undefined+ callback.
|
176
|
+
|
177
|
+
class Y
|
178
|
+
include NoBacksies::Callbacks
|
179
|
+
|
180
|
+
def self.list
|
181
|
+
@list ||= []
|
182
|
+
end
|
183
|
+
|
184
|
+
callback :method_undefined do |method|
|
185
|
+
list << method
|
186
|
+
end
|
187
|
+
|
188
|
+
def foo; end
|
189
|
+
def bar; end
|
190
|
+
|
191
|
+
undef_method(:foo)
|
192
|
+
undef_method(:bar)
|
193
|
+
end
|
194
|
+
|
195
|
+
Then the results are as follows.
|
196
|
+
|
197
|
+
Y.list #=> [:foo, :bar]
|
198
|
+
|
199
|
+
|
200
|
+
== Singleton Method Added
|
201
|
+
|
202
|
+
Given a class that defines a no-backsies +singleton_method_added+ callback.
|
203
|
+
|
204
|
+
class Y
|
205
|
+
include NoBacksies::Callbacks
|
206
|
+
|
207
|
+
def self.list
|
208
|
+
@list ||= []
|
209
|
+
end
|
210
|
+
|
211
|
+
callback :singleton_method_added do |method|
|
212
|
+
list << method
|
213
|
+
end
|
214
|
+
|
215
|
+
def self.foo; end
|
216
|
+
def self.bar; end
|
217
|
+
end
|
218
|
+
|
219
|
+
Then the results are as follows.
|
220
|
+
|
221
|
+
Y.list #=> [:foo, :bar]
|
222
|
+
|
223
|
+
|
224
|
+
== Singleton Method Removed
|
225
|
+
|
226
|
+
Given a class that defines a no-backsies +singleton_method_removed+ callback.
|
227
|
+
|
228
|
+
class Y
|
229
|
+
include NoBacksies::Callbacks
|
230
|
+
|
231
|
+
def self.list
|
232
|
+
@list ||= []
|
233
|
+
end
|
234
|
+
|
235
|
+
callback :singleton_method_removed do |method|
|
236
|
+
list << method
|
237
|
+
end
|
238
|
+
|
239
|
+
def self.foo; end
|
240
|
+
def self.bar; end
|
241
|
+
|
242
|
+
class << self
|
243
|
+
remove_method(:foo)
|
244
|
+
remove_method(:bar)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
Then the results are as follows.
|
249
|
+
|
250
|
+
Y.list #=> [:foo, :bar]
|
251
|
+
|
252
|
+
|
253
|
+
== Singleton Method Undefined
|
254
|
+
|
255
|
+
class Y
|
256
|
+
include NoBacksies::Callbacks
|
257
|
+
|
258
|
+
def self.list
|
259
|
+
@list ||= []
|
260
|
+
end
|
261
|
+
|
262
|
+
callback :singleton_method_undefined do |method|
|
263
|
+
list << method
|
264
|
+
end
|
265
|
+
|
266
|
+
def self.foo; end
|
267
|
+
def self.bar; end
|
268
|
+
|
269
|
+
class << self
|
270
|
+
undef_method(:foo)
|
271
|
+
undef_method(:bar)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
Y.list #=> [:foo, :bar]
|
276
|
+
|
277
|
+
|
278
|
+
= Constant Missing
|
279
|
+
|
280
|
+
Given a class that defines a no-backsies +const_missing+ callback.
|
281
|
+
|
282
|
+
class Y
|
283
|
+
include NoBacksies::Callbacks
|
284
|
+
|
285
|
+
def self.list
|
286
|
+
@list ||= []
|
287
|
+
end
|
288
|
+
|
289
|
+
callback :const_missing do |const|
|
290
|
+
list << const
|
291
|
+
end
|
292
|
+
|
293
|
+
FOO
|
294
|
+
BAR
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
Then the results are as follows.
|
299
|
+
|
300
|
+
Y.list #=> [:FOO, :BAR]
|
301
|
+
|
302
|
+
|
303
|
+
= Included
|
304
|
+
|
305
|
+
Given a class that defines a no-backsies +included+ callback.
|
306
|
+
|
307
|
+
module U
|
308
|
+
include NoBacksies::Callbacks
|
309
|
+
|
310
|
+
def self.list
|
311
|
+
@list ||= []
|
312
|
+
end
|
313
|
+
|
314
|
+
callback :included do |mod|
|
315
|
+
list << mod
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
class X
|
320
|
+
include U
|
321
|
+
end
|
322
|
+
|
323
|
+
class Y
|
324
|
+
include U
|
325
|
+
end
|
326
|
+
|
327
|
+
Then the results are as follows.
|
328
|
+
|
329
|
+
U.list #=> [X, Y]
|
330
|
+
|
331
|
+
|
332
|
+
= Extended
|
333
|
+
|
334
|
+
Given a class that defines a no-backsies +extended+ callback.
|
335
|
+
|
336
|
+
module U
|
337
|
+
include NoBacksies::Callbacks
|
338
|
+
|
339
|
+
def self.list
|
340
|
+
@list ||= []
|
341
|
+
end
|
342
|
+
|
343
|
+
callback :extended do |mod|
|
344
|
+
list << mod
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
class X
|
349
|
+
extend U
|
350
|
+
end
|
351
|
+
|
352
|
+
class Y
|
353
|
+
extend U
|
354
|
+
end
|
355
|
+
|
356
|
+
Then the results are as follows.
|
357
|
+
|
358
|
+
U.list #=> [X, Y]
|
359
|
+
|
360
|
+
|
361
|
+
= Inherited
|
362
|
+
|
363
|
+
Given a class that defines a no-backsies +inherited+ callback.
|
364
|
+
|
365
|
+
class Y
|
366
|
+
include NoBacksies::Callbacks
|
367
|
+
|
368
|
+
def self.list
|
369
|
+
@list ||= []
|
370
|
+
end
|
371
|
+
|
372
|
+
callback :inherited do |base|
|
373
|
+
list << base
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
z = Class.new(Y)
|
378
|
+
|
379
|
+
Then the results are as follows.
|
380
|
+
|
381
|
+
Y.list #=> [z]
|
382
|
+
|
383
|
+
|
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== DESCRIPTION
|
4
4
|
|
5
|
-
|
5
|
+
NoBacksies is a callback layer built on top of Ruby's built-in callback
|
6
6
|
methods. It makes it possible to add new callbacks very easily, without
|
7
7
|
having to fuss with more nuanced issues of defining and redefining callback
|
8
8
|
methods.
|
data/lib/no_backsies.rb
CHANGED
@@ -58,7 +58,6 @@
|
|
58
58
|
module NoBacksies
|
59
59
|
|
60
60
|
#
|
61
|
-
|
62
61
|
module Callbacks
|
63
62
|
# Apply all supported callback modules.
|
64
63
|
def self.append_features(base)
|
@@ -72,6 +71,7 @@ module NoBacksies
|
|
72
71
|
base.extend ConstMissing
|
73
72
|
base.extend Included
|
74
73
|
base.extend Extended
|
74
|
+
base.extend Inherited
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -227,7 +227,7 @@ module NoBacksies
|
|
227
227
|
|
228
228
|
#
|
229
229
|
def const_missing(const)
|
230
|
-
callback_invoke(:const_missing,
|
230
|
+
callback_invoke(:const_missing, const)
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
@@ -241,7 +241,7 @@ module NoBacksies
|
|
241
241
|
|
242
242
|
#
|
243
243
|
def included(mod)
|
244
|
-
callback_invoke(:included,
|
244
|
+
callback_invoke(:included, mod)
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
@@ -255,7 +255,7 @@ module NoBacksies
|
|
255
255
|
|
256
256
|
#
|
257
257
|
def extended(mod)
|
258
|
-
callback_invoke(:extended,
|
258
|
+
callback_invoke(:extended, mod)
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
@@ -268,8 +268,8 @@ module NoBacksies
|
|
268
268
|
end
|
269
269
|
|
270
270
|
#
|
271
|
-
def
|
272
|
-
callback_invoke(:inherited,
|
271
|
+
def inherited(base)
|
272
|
+
callback_invoke(:inherited, base)
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
== Method Added
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +method_added+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :method_added do |method|
|
13
|
+
list << method
|
14
|
+
end
|
15
|
+
|
16
|
+
def foo; end
|
17
|
+
def bar; end
|
18
|
+
end
|
19
|
+
|
20
|
+
Then the results are as follows.
|
21
|
+
|
22
|
+
Y.list #=> [:foo, :bar]
|
23
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
== Method Removed
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +method_removed+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :method_removed do |method|
|
13
|
+
list << method
|
14
|
+
end
|
15
|
+
|
16
|
+
def foo; end
|
17
|
+
def bar; end
|
18
|
+
|
19
|
+
remove_method(:foo)
|
20
|
+
remove_method(:bar)
|
21
|
+
end
|
22
|
+
|
23
|
+
Then the results are as follows.
|
24
|
+
|
25
|
+
Y.list #=> [:foo, :bar]
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
== Method Undefined
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +method_undefined+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :method_undefined do |method|
|
13
|
+
list << method
|
14
|
+
end
|
15
|
+
|
16
|
+
def foo; end
|
17
|
+
def bar; end
|
18
|
+
|
19
|
+
undef_method(:foo)
|
20
|
+
undef_method(:bar)
|
21
|
+
end
|
22
|
+
|
23
|
+
Then the results are as follows.
|
24
|
+
|
25
|
+
Y.list #=> [:foo, :bar]
|
26
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
== Singleton Method Added
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +singleton_method_added+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :singleton_method_added do |method|
|
13
|
+
list << method
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.foo; end
|
17
|
+
def self.bar; end
|
18
|
+
end
|
19
|
+
|
20
|
+
Then the results are as follows.
|
21
|
+
|
22
|
+
Y.list #=> [:foo, :bar]
|
23
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== Singleton Method Removed
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +singleton_method_removed+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :singleton_method_removed do |method|
|
13
|
+
list << method
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.foo; end
|
17
|
+
def self.bar; end
|
18
|
+
|
19
|
+
class << self
|
20
|
+
remove_method(:foo)
|
21
|
+
remove_method(:bar)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Then the results are as follows.
|
26
|
+
|
27
|
+
Y.list #=> [:foo, :bar]
|
28
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
== Singleton Method Undefined
|
2
|
+
|
3
|
+
class Y
|
4
|
+
include NoBacksies::Callbacks
|
5
|
+
|
6
|
+
def self.list
|
7
|
+
@list ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
callback :singleton_method_undefined do |method|
|
11
|
+
list << method
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.foo; end
|
15
|
+
def self.bar; end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
undef_method(:foo)
|
19
|
+
undef_method(:bar)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Y.list #=> [:foo, :bar]
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
= Constant Missing
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +const_missing+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :const_missing do |const|
|
13
|
+
list << const
|
14
|
+
end
|
15
|
+
|
16
|
+
FOO
|
17
|
+
BAR
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
Then the results are as follows.
|
22
|
+
|
23
|
+
Y.list #=> [:FOO, :BAR]
|
24
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
= Included
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +included+ callback.
|
4
|
+
|
5
|
+
module U
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :included do |mod|
|
13
|
+
list << mod
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class X
|
18
|
+
include U
|
19
|
+
end
|
20
|
+
|
21
|
+
class Y
|
22
|
+
include U
|
23
|
+
end
|
24
|
+
|
25
|
+
Then the results are as follows.
|
26
|
+
|
27
|
+
U.list #=> [X, Y]
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
= Extended
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +extended+ callback.
|
4
|
+
|
5
|
+
module U
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :extended do |mod|
|
13
|
+
list << mod
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class X
|
18
|
+
extend U
|
19
|
+
end
|
20
|
+
|
21
|
+
class Y
|
22
|
+
extend U
|
23
|
+
end
|
24
|
+
|
25
|
+
Then the results are as follows.
|
26
|
+
|
27
|
+
U.list #=> [X, Y]
|
28
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
= Inherited
|
2
|
+
|
3
|
+
Given a class that defines a no-backsies +inherited+ callback.
|
4
|
+
|
5
|
+
class Y
|
6
|
+
include NoBacksies::Callbacks
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
@list ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
callback :inherited do |base|
|
13
|
+
list << base
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
z = Class.new(Y)
|
18
|
+
|
19
|
+
Then the results are as follows.
|
20
|
+
|
21
|
+
Y.list #=> [z]
|
22
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: no_backsies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas Sawyer
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id002
|
37
37
|
description: |-
|
38
|
-
|
38
|
+
NoBacksies is a callback layer built on top of Ruby's built-in callback
|
39
39
|
methods. It makes it possible to add new callbacks very easily, without
|
40
40
|
having to fuss with more nuanced issues of defining and redefining callback
|
41
41
|
methods.
|
@@ -52,11 +52,22 @@ files:
|
|
52
52
|
- qed/02_express.rdoc
|
53
53
|
- qed/03_options.rdoc
|
54
54
|
- qed/applique/no_backsies.rb
|
55
|
+
- qed/callbacks/01_method_added.rdoc
|
56
|
+
- qed/callbacks/02_method_removed.rdoc
|
57
|
+
- qed/callbacks/03_method_undefined.rdoc
|
58
|
+
- qed/callbacks/04_singleton_method_added.rdoc
|
59
|
+
- qed/callbacks/05_singleton_method_removed.rdoc
|
60
|
+
- qed/callbacks/06_singleton_method_undefined.rdoc
|
61
|
+
- qed/callbacks/07_const_missing.rdoc
|
62
|
+
- qed/callbacks/08_included.rdoc
|
63
|
+
- qed/callbacks/09_extended.rdoc
|
64
|
+
- qed/callbacks/10_inherited.rdoc
|
55
65
|
- HISTORY.rdoc
|
56
66
|
- README.rdoc
|
67
|
+
- QED.rdoc
|
57
68
|
- COPYING.rdoc
|
58
69
|
- NOTICE.rdoc
|
59
|
-
homepage: http://rubyworks.github.com/
|
70
|
+
homepage: http://rubyworks.github.com/no_backsies
|
60
71
|
licenses: []
|
61
72
|
|
62
73
|
post_install_message:
|