rubapi 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2597f56a8187b718cceece6bf7712d999d0cc662
4
- data.tar.gz: fb49c215d90deb47b3ef40756c63dd8ff50e3eb8
3
+ metadata.gz: 704f4477b893928e583d280a116813857aa95a57
4
+ data.tar.gz: c98bdcc21e38870f23da11e6f8e895992fcec647
5
5
  SHA512:
6
- metadata.gz: 718826ba798f16f4ca39419809ebf9f3c0f4612c4f1142a71a8f5e68391fd17ccc0a6f21c754feb0050cff549dbd2cfd3398639549b78a70c31b683c11c56919
7
- data.tar.gz: 551b8cdbf3b9624161d144c87ff3b0402044c078c31ecb6aa6035cd04abdb4181175eadd29d7a917708ece39e53ca65f8af7950973c503bf747d09288c6be718
6
+ metadata.gz: 0bb28b1fd4d41b7335a2ea80b9059ebb3cc2c3574c0d3c46889dedfbb08c4215ed6dfc21da68e733024355908ec7b0a429af56f70754855e52df8b1b5b5c9185
7
+ data.tar.gz: 07f330a8c4d8229fe4b3126e1c217cffb0ba43449a97ef488991170d1f5ec17efb66269f9d53a2bffc205b1a1921d4d7c4e22e2f448b7e2de0b1f2ee6e8d19a3
@@ -60,6 +60,7 @@ module Rubapi
60
60
  route[:controller] ||= self.class
61
61
  controller = route[:controller].new(self.response)
62
62
  controller.request = self.request
63
+ controller.request.pagination = route[:pagination] unless route[:pagination].nil?
63
64
  controller.send(route[:method])
64
65
  end
65
66
 
@@ -77,12 +78,12 @@ module Rubapi
77
78
  EM.defer get_conn, callback
78
79
  end
79
80
 
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
81
+ # If you try to respond with a reql.expr, it ensures that will return with a Hash(Dict) format
82
+ def format_response(response)
83
+ response.map {|re|
84
+ { :"#{re.first}" => re.last }
85
+ }.inject({}) {|sum, re| sum.merge!(re)}
86
+ end
86
87
 
87
88
  def attach_data(data)
88
89
  @content ||= { errors: [] }
@@ -2,14 +2,22 @@ module Rubapi
2
2
  class Request
3
3
  attr_accessor :params,
4
4
  :errors,
5
- :route
5
+ :route,
6
+ :pagination
6
7
 
7
8
  def initialize
8
9
  self.params = {}
10
+ self.pagination = default_pagination
9
11
  end
10
12
 
11
13
  def parse(param_string)
12
14
  self.params = self.params.merge(Rack::Utils.parse_nested_query(param_string))
13
15
  end
16
+
17
+ def default_pagination
18
+ {
19
+ per_page: 10
20
+ }
21
+ end
14
22
  end
15
23
  end
@@ -27,11 +27,9 @@ module Rubapi
27
27
  resources[:actions][verb].each do |re|
28
28
  resource_path = re[:path].split("/")
29
29
  if paths.count == resource_path.count
30
- params = resource_path.select{|pa| /:([a-z_]+)/.match pa }
31
-
32
30
  request = re.clone
33
- request[:params] = extract_params(paths, params)
34
31
  request[:controller] = resources[:controller]
32
+ request[:pagination] = resources[:pagination]
35
33
  return request
36
34
  end
37
35
  end
@@ -80,7 +78,8 @@ module Rubapi
80
78
  delete:[]
81
79
  },
82
80
  nested: [],
83
- controller: nil
81
+ controller: nil,
82
+ pagination: nil
84
83
  }
85
84
  end
86
85
 
@@ -109,6 +108,10 @@ module Rubapi
109
108
  def controller(klass)
110
109
  @current_resource[:controller] = klass
111
110
  end
111
+
112
+ def pagination(options)
113
+ @current_resource[:pagination] = options
114
+ end
112
115
  end
113
116
  end
114
117
  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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo K. Sasaki