tanga_namespaced_helpers 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module TangaNamespacedHelpers
|
|
6
6
|
def self.reset! controller
|
7
7
|
@view = controller.view_context
|
8
8
|
if controller.is_a?(ActionController::Base)
|
9
|
-
@
|
9
|
+
@original_context = @view
|
10
10
|
end
|
11
11
|
|
12
12
|
# Hack to get Haml helpers available
|
@@ -22,8 +22,8 @@ module TangaNamespacedHelpers
|
|
22
22
|
@view
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.
|
26
|
-
@
|
25
|
+
def self.use_controller!
|
26
|
+
@view = @original_context
|
27
27
|
end
|
28
28
|
|
29
29
|
# TODO Gotta be a better way to do this.
|
@@ -31,25 +31,15 @@ module TangaNamespacedHelpers
|
|
31
31
|
TangaNamespacedHelpers.view
|
32
32
|
end
|
33
33
|
|
34
|
-
def controller
|
35
|
-
TangaNamespacedHelpers.controller
|
36
|
-
end
|
37
|
-
|
38
34
|
def method_missing *args, &block
|
39
|
-
retry_count ||= 0
|
40
35
|
view.send *args, &block
|
41
36
|
rescue NoMethodError
|
42
37
|
# This is pretty stupid. ActionMailer sometimes resets the current view context.
|
43
38
|
# So, if there's a NoMethodError (i.e. access the session after ActionMailer
|
44
39
|
# resets the context), we need to reset it to the original controller
|
45
40
|
# for the request and try one more time.
|
46
|
-
|
47
|
-
|
48
|
-
retry_count += 1
|
49
|
-
retry
|
50
|
-
else
|
51
|
-
raise
|
52
|
-
end
|
41
|
+
TangaNamespacedHelpers.use_controller!
|
42
|
+
view.send *args, &block
|
53
43
|
end
|
54
44
|
|
55
45
|
module ControllerMethods
|