rack-jquery-params 0.1.1 → 0.2.0

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: ce3c91709327a9b32de8dadfaf39134e97619250
4
- data.tar.gz: bf9357248ce5c3bc4ec440495926cd03e6ba265c
3
+ metadata.gz: 18389012615ac37ddcf3655ef105a4cb7a41a02e
4
+ data.tar.gz: 38b8a88405e234cf388ed6fcf6968b0933a0e135
5
5
  SHA512:
6
- metadata.gz: 78eccab00c7212b0dc7a449776498c6b5702b5023e3c54c55aedcb1005c5ac615b02ed44d585af8813f516cb40b3da5494f7eb0bf77bfdcdfa352da72f377e5a
7
- data.tar.gz: 9eb1f64ff1911b2573dc72ce06cf1b5aee5535260950faae72ba4ee114fa794d4b0eb6a14ad32707fc5b976df8e952a864842d07caa67c903bb98ee756bb86e3
6
+ metadata.gz: 8486aceb8fc6a32793a62232bdb7c7955393efa8ca66ea2e07bd239cc86b3e5a33318921e0e25e1eeb45c8cf8e194bffb1b5bcc5948cbddb6954ef1cfbb7082f
7
+ data.tar.gz: 58e006ec024afea9ad55f6ed97212b064af05b9ff275d4cca550b941bd4eff5b4d42e2b91b7e1f0d68d09eced5f9f667a12376f1845a72062ff0500f317afd1e
@@ -1,5 +1,6 @@
1
1
  require 'rack'
2
2
 
3
+ # Loops through all params and convert the hashes to arrays only if all keys are comprised of integers.
3
4
  module Rack
4
5
  class JQueryParams
5
6
  include Rack::Utils
@@ -12,8 +13,6 @@ module Rack
12
13
  @app = app
13
14
  end
14
15
 
15
- # Loops through all params and convert the hashes to arrays only if all keys are comprised of integers.
16
- #
17
16
  def call(env)
18
17
  status, headers, response = @app.call(env)
19
18
 
@@ -24,22 +23,22 @@ module Rack
24
23
  def self.fix(env, valid_methods=:all)
25
24
  valid_methods = extract_valid_methods(valid_methods)
26
25
  return if valid_methods != :all and !valid_methods.include?(env['REQUEST_METHOD'])
27
- fix_param(env['rack.request.query_hash'])
28
- fix_param(env['rack.request.form_hash'])
26
+ fix_params(env['rack.request.query_hash'])
27
+ fix_params(env['rack.request.form_hash'])
29
28
  end
30
29
 
31
- def self.fix_param(param)
32
- if param.is_a?(Hash)
33
- if param.all?{|k,v| k =~ /^[0-9]+$/}
34
- param.sort.inject([]){|result, v| result << fix_param(v[1]) }
30
+ def self.fix_params(params)
31
+ if params.is_a?(Hash)
32
+ if params.all?{|k,v| k =~ /^[0-9]+$/}
33
+ params.sort.inject([]){|result, v| result << fix_params(v[1]) }
35
34
  else
36
- param.each{|k,v| param[k] = fix_param(v)}
35
+ params.each{|k,v| params[k] = fix_params(v) }
37
36
  end
38
- elsif param.is_a?(Array)
39
- param.each_with_index {|v,i| param[i] = fix_param(v) }
40
- return param
37
+ elsif params.is_a?(Array)
38
+ params.each_with_index {|v,i| params[i] = fix_params(v) }
39
+ return params
41
40
  else
42
- return param
41
+ return params
43
42
  end
44
43
  end
45
44
 
@@ -1,3 +1,3 @@
1
1
  class Rack::JQueryParams
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jquery-params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark