rack-param 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rack/param.rb +13 -9
  3. data/rack-param.gemspec +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e28551b58efd27381475b314285441fb507ad777
4
- data.tar.gz: a89a6c2ecacdec04cba1f9c276e61e2cd723c974
3
+ metadata.gz: ba04656ba303a1a216387553f0cf6db3e70d616e
4
+ data.tar.gz: 770275431e757b4ebe6530b4632b225302656c25
5
5
  SHA512:
6
- metadata.gz: 9149676d8cd3704effeac4e9ab0b890c939a434c1a1b2c9d73972032588dde17789ec986cca7f0f7a6e3191082f11d237ec82b38354067235d5e4c38e3358d5e
7
- data.tar.gz: 3821d3b30871f9a178571de3200226701867d9e69e604747adad5ccfca95518ca40c4330742ad5524d402550703d5163becc6871e9cb4de97f922ec183fb7946
6
+ metadata.gz: 41c0ab7e6907d9890f38ba72442bce6112230f5ab8837b0ccbe566cde5dce478a4a38279fc3505a2eb66d1555ba91bebec48ac38eb7e75aa5a23e800547d24d8
7
+ data.tar.gz: 4f55ca7bbb61cddf6dfcadb153a4212315fd3e201a3415b6971f2ed7ca69d29f0d64e075cd43df73d6676458869175303ccd559c69ebdb051f16dd4d018861fd
data/lib/rack/param.rb CHANGED
@@ -28,15 +28,17 @@ module Rack
28
28
  def param name, type, opts={}
29
29
  _name = name.to_s
30
30
 
31
- p = Rack::Parameter.new(
32
- :name => _name,
33
- :value => params_original[_name] || params[_name],
34
- :type => type,
35
- :conditions => opts
36
- )
31
+ if params_original.member? _name
32
+ p = Rack::Parameter.new(
33
+ :name => _name,
34
+ :value => params_original[_name] || params[_name],
35
+ :type => type,
36
+ :conditions => opts
37
+ )
37
38
 
38
- raise ParameterError, p.error unless p.valid?
39
- params[_name] = p.value
39
+ raise ParameterError, p.error unless p.valid?
40
+ params[_name] = p.value
41
+ end
40
42
  end
41
43
  end
42
44
 
@@ -93,7 +95,9 @@ module Rack
93
95
  def process opts
94
96
  return "Parameter #{@name} is required." if @value.nil? && required?
95
97
 
96
- unless @value.class == @type
98
+ puts "VALUE for (#{@name}): " + @value.inspect
99
+
100
+ unless @value.class == @type || @value.nil?
97
101
  begin
98
102
  @value = case @type.to_s.downcase.to_sym
99
103
  when :date then Date.parse @value
data/rack-param.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rack-param"
7
- spec.version = "0.1.4"
7
+ spec.version = "0.1.5"
8
8
  spec.authors = ["Nathaniel Symer"]
9
9
  spec.email = ["nate@natesymer.com"]
10
10
  spec.summary = "Sane parameter validation for Rack::Request."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-param
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathaniel Symer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.2.2
79
+ rubygems_version: 2.4.5
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Sane parameter validation for Rack::Request.