rango 0.1.1.2.2 → 0.1.1.2.3
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/lib/rango/controller.rb +10 -7
- data/lib/rango/mixins/filters.rb +9 -2
- data/lib/rango/version.rb +1 -1
- metadata +1 -1
data/lib/rango/controller.rb
CHANGED
@@ -20,11 +20,18 @@ module Rango
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_response
|
23
|
-
method =
|
24
|
-
|
23
|
+
method = request.env["rango.controller.action"].to_sym
|
24
|
+
if self.respond_to?(method) # TODO: what about method_missing?
|
25
|
+
self.process_action(method)
|
26
|
+
else
|
25
27
|
raise NotFound, "Controller #{self.class.name} doesn't have method #{method}"
|
26
28
|
end
|
27
|
-
self.
|
29
|
+
return self.response.finish
|
30
|
+
rescue HttpError => exception
|
31
|
+
self.rescue_http_error(exception)
|
32
|
+
end
|
33
|
+
|
34
|
+
def process_action(method)
|
28
35
|
# If you don't care about arguments or if you prefer usage of params.
|
29
36
|
if self.method(method).arity.eql?(0)
|
30
37
|
Rango.logger.debug("Calling method #{self.class.name}##{method} without arguments")
|
@@ -34,10 +41,6 @@ module Rango
|
|
34
41
|
Rango.logger.debug("Calling method #{self.class.name}##{method} with arguments #{args.inspect}")
|
35
42
|
self.response.body = self.method(method).call(*args)
|
36
43
|
end
|
37
|
-
self.run_filters(:after, method)
|
38
|
-
return self.response.finish
|
39
|
-
rescue HttpError => exception
|
40
|
-
self.rescue_http_error(exception)
|
41
44
|
end
|
42
45
|
|
43
46
|
# for routers
|
data/lib/rango/mixins/filters.rb
CHANGED
@@ -6,6 +6,13 @@ module Rango
|
|
6
6
|
controller.extend(ClassMethods)
|
7
7
|
end
|
8
8
|
|
9
|
+
# for Rango::Controller
|
10
|
+
def process_action(method)
|
11
|
+
self.run_filters(:before, method)
|
12
|
+
super(method)
|
13
|
+
self.run_filters(:after, method)
|
14
|
+
end
|
15
|
+
|
9
16
|
# @since 0.0.2
|
10
17
|
def run_filters(name, method)
|
11
18
|
# Rango.logger.debug(self.class.instance_variables)
|
@@ -24,7 +31,7 @@ module Rango
|
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
27
|
-
|
34
|
+
|
28
35
|
module ClassMethods
|
29
36
|
def inherited(subclass)
|
30
37
|
inherit_filters(subclass, :before)
|
@@ -66,5 +73,5 @@ module Rango
|
|
66
73
|
attribute :before_display_filters, Array.new
|
67
74
|
attribute :after_display_filters, Array.new
|
68
75
|
end
|
69
|
-
end
|
76
|
+
end
|
70
77
|
end
|
data/lib/rango/version.rb
CHANGED