goat 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/goat.rb +19 -0
- metadata +3 -3
data/lib/goat.rb
CHANGED
@@ -272,6 +272,7 @@ module Goat
|
|
272
272
|
|
273
273
|
def initialize
|
274
274
|
@before_handler_bindings = {}
|
275
|
+
@after_handler_bindings = {}
|
275
276
|
end
|
276
277
|
|
277
278
|
class ::Proc
|
@@ -309,12 +310,22 @@ module Goat
|
|
309
310
|
@before_handler_bindings[handler] ||= App.bind(handler)
|
310
311
|
end
|
311
312
|
|
313
|
+
def after_handler_binding(handler)
|
314
|
+
@after_handler_bindings[handler] ||= App.bind(handler)
|
315
|
+
end
|
316
|
+
|
312
317
|
def run_before_handlers(app)
|
313
318
|
app.class.before_handlers.each do |handler|
|
314
319
|
before_handler_binding(handler).call(app)
|
315
320
|
end
|
316
321
|
end
|
317
322
|
|
323
|
+
def run_after_handlers(app)
|
324
|
+
app.class.after_handlers.each do |handler|
|
325
|
+
after_handler_binding(handler).call(app)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
318
329
|
def resp_for_error(e, app)
|
319
330
|
resp = nil
|
320
331
|
|
@@ -373,6 +384,8 @@ module Goat
|
|
373
384
|
rescue Exception => e
|
374
385
|
resp = resp_for_error(e, app)
|
375
386
|
end
|
387
|
+
|
388
|
+
run_after_handlers(app)
|
376
389
|
|
377
390
|
resp.to_a
|
378
391
|
end
|
@@ -524,6 +537,7 @@ module Goat
|
|
524
537
|
@@active_pages = {}
|
525
538
|
@@active_page_queue = Queue.new
|
526
539
|
@@before_handlers = []
|
540
|
+
@@after_handlers = []
|
527
541
|
|
528
542
|
def active_pages; @@active_pages; end
|
529
543
|
def active_page_queue; @@active_page_queue; end
|
@@ -571,10 +585,15 @@ module Goat
|
|
571
585
|
end
|
572
586
|
|
573
587
|
def before_handlers; @@before_handlers; end
|
588
|
+
def after_handlers; @@after_handlers; end
|
574
589
|
|
575
590
|
def before(&blk)
|
576
591
|
before_handlers << blk
|
577
592
|
end
|
593
|
+
|
594
|
+
def after(&blk)
|
595
|
+
after_handlers << blk
|
596
|
+
end
|
578
597
|
|
579
598
|
def enable_notifications(opts={})
|
580
599
|
NotificationCenter.configure(opts)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 9
|
10
|
+
version: 0.2.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Collison
|