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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f64ded3bcce4f8d995217cb9cb3685ecaeba586d
4
- data.tar.gz: 0d9e139e6d2c89be73ea1d992df7c3314f25e2b1
3
+ metadata.gz: 2597f56a8187b718cceece6bf7712d999d0cc662
4
+ data.tar.gz: fb49c215d90deb47b3ef40756c63dd8ff50e3eb8
5
5
  SHA512:
6
- metadata.gz: 8df848ff4325ade85a3d961cb4cf948846e38bea18208df0901d5b2d42b0e58fb6def9e8412164b77ecbda045db34be253a84b12e39d3baa71839506d16304c4
7
- data.tar.gz: cb33ed84825739b36692af35790de45af61b273a5653e59edec82686b5907b60adeb369aa48fe1f90dddeb1bd568ffd2f3140764acbd195a1a3f71bffe08fe0e
6
+ metadata.gz: 718826ba798f16f4ca39419809ebf9f3c0f4612c4f1142a71a8f5e68391fd17ccc0a6f21c754feb0050cff549dbd2cfd3398639549b78a70c31b683c11c56919
7
+ data.tar.gz: 551b8cdbf3b9624161d144c87ff3b0402044c078c31ecb6aa6035cd04abdb4181175eadd29d7a917708ece39e53ca65f8af7950973c503bf747d09288c6be718
data/lib/rubapi.rb CHANGED
@@ -4,6 +4,7 @@ require "evma_httpserver"
4
4
  require "json"
5
5
  require_relative "rubapi/router"
6
6
  require_relative "rubapi/controller"
7
+ require_relative "rubapi/request"
7
8
  require_relative "rubapi/server"
8
9
 
9
10
 
@@ -59,14 +59,14 @@ module Rubapi
59
59
 
60
60
  route[:controller] ||= self.class
61
61
  controller = route[:controller].new(self.response)
62
- controller.params = self.params
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
- handle = reql_expression.run(conn) do |row|
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;
@@ -4,13 +4,11 @@ module Rubapi
4
4
  :errors,
5
5
  :route
6
6
 
7
- def initialize(route)
8
- self.route = route
7
+ def initialize
9
8
  self.params = {}
10
- self.errors = []
11
9
  end
12
10
 
13
- def parse_params(param_string)
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
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo K. Sasaki