rubapi 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubapi.rb +1 -0
- data/lib/rubapi/controller.rb +9 -2
- data/lib/rubapi/request.rb +2 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2597f56a8187b718cceece6bf7712d999d0cc662
|
4
|
+
data.tar.gz: fb49c215d90deb47b3ef40756c63dd8ff50e3eb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 718826ba798f16f4ca39419809ebf9f3c0f4612c4f1142a71a8f5e68391fd17ccc0a6f21c754feb0050cff549dbd2cfd3398639549b78a70c31b683c11c56919
|
7
|
+
data.tar.gz: 551b8cdbf3b9624161d144c87ff3b0402044c078c31ecb6aa6035cd04abdb4181175eadd29d7a917708ece39e53ca65f8af7950973c503bf747d09288c6be718
|
data/lib/rubapi.rb
CHANGED
data/lib/rubapi/controller.rb
CHANGED
@@ -59,14 +59,14 @@ module Rubapi
|
|
59
59
|
|
60
60
|
route[:controller] ||= self.class
|
61
61
|
controller = route[:controller].new(self.response)
|
62
|
-
controller.
|
62
|
+
controller.request = self.request
|
63
63
|
controller.send(route[:method])
|
64
64
|
end
|
65
65
|
|
66
66
|
def process_defer(reql_expression)
|
67
67
|
get_conn = proc{ ReconnectionPool.get }
|
68
68
|
callback = proc{|conn|
|
69
|
-
|
69
|
+
reql_expression.run(conn) do |row|
|
70
70
|
yield(row.to_a) if block_given?
|
71
71
|
end
|
72
72
|
|
@@ -77,6 +77,13 @@ module Rubapi
|
|
77
77
|
EM.defer get_conn, callback
|
78
78
|
end
|
79
79
|
|
80
|
+
# If you try to respond with a reql.expr, it ensures that will return if a Hash(Dict) format
|
81
|
+
def format_response(response)
|
82
|
+
response.map {|re|
|
83
|
+
{ :"#{re.first}" => re.last }
|
84
|
+
}.inject({}) {|sum, re| sum.merge!(re)}
|
85
|
+
end
|
86
|
+
|
80
87
|
def attach_data(data)
|
81
88
|
@content ||= { errors: [] }
|
82
89
|
@content[:data] = data;
|
data/lib/rubapi/request.rb
CHANGED
@@ -4,13 +4,11 @@ module Rubapi
|
|
4
4
|
:errors,
|
5
5
|
:route
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
self.route = route
|
7
|
+
def initialize
|
9
8
|
self.params = {}
|
10
|
-
self.errors = []
|
11
9
|
end
|
12
10
|
|
13
|
-
def
|
11
|
+
def parse(param_string)
|
14
12
|
self.params = self.params.merge(Rack::Utils.parse_nested_query(param_string))
|
15
13
|
end
|
16
14
|
end
|