rubapi 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubapi/controller.rb +23 -1
  3. metadata +29 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f80b8e96bec40c2a7c6387864e9ec04a81d95bac
4
- data.tar.gz: 86323cc0ce6788ac329f80430588c097c8100f6c
3
+ metadata.gz: 4d61507abadf47b27b31c185bb009b363e36b1ee
4
+ data.tar.gz: 57ec61dcbff68c3227fd07b70520e76745f008f0
5
5
  SHA512:
6
- metadata.gz: e29fa72ced6467304b78573ae5e866878b31ff5fa03dc5598e7f78fa529bd02e08e6b7b66fd972d71a3bcce4aaf50cfa0ffe19d941e06138c821a0d67941e98d
7
- data.tar.gz: 721678a8a5c297226783aa4630b82c2c3b7cb39a774954f07f8a8a8fb81c21cd8adb41db19704cfe15fddfcdcd984fe3c5d68ed570a10eed3b84de3e3be380f3
6
+ metadata.gz: e9c2408415005ff412c557465710190b9f0edb248612163faefa8980acce42b239f9a2809575da3e71db03d3c6481b18cf45897b3d8cfbac559d0e94632b7a7c
7
+ data.tar.gz: 9a5aad8abe25c0b1e4970143d380eac0e1bedcdf923300ef3b54c9203837e8ee75c6a425a36b3940f57d2c067edce80d230580bc91c4daac393374819ca6c5f7
@@ -39,7 +39,7 @@ module Rubapi
39
39
  r.status = 200
40
40
 
41
41
  begin
42
- r.content = JSON.generate(content)
42
+ r.content = JSON.generate(attach_data(content))
43
43
  rescue
44
44
  r.content = "{\"errors\":[\"can't generate a json object\"]}"
45
45
  r.status = 417 #Execution failed
@@ -62,5 +62,27 @@ module Rubapi
62
62
  controller.params = self.params
63
63
  controller.send(route[:method])
64
64
  end
65
+
66
+ def process_defer(reql_expression)
67
+ get_conn = proc{ ReconnectionPool.get }
68
+ callback = proc{|conn|
69
+ handle = reql_expression.run(conn) do |row|
70
+ yield(row.to_a) if block_given?
71
+ end
72
+
73
+ ReconnectionPool.return conn
74
+ send_response(nil) unless block_given?
75
+ }
76
+
77
+ EM.defer get_conn, callback
78
+ end
79
+
80
+ def attach_data(data)
81
+ @content ||= { errors: [] }
82
+ @content[:data] = data;
83
+
84
+ @content
85
+ end
86
+
65
87
  end
66
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo K. Sasaki
@@ -38,6 +38,34 @@ dependencies:
38
38
  version: '0'
39
39
  prerelease: false
40
40
  type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: rethinkdb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: reconnection_pool
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ prerelease: false
68
+ type: :runtime
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rack
43
71
  requirement: !ruby/object:Gem::Requirement