rails_param 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/rails_param/param.rb +9 -1
- data/lib/rails_param/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 78f71c8a36c9b2fc080a205733b8eef0d89a04db299ed3703bb333e08d00c8de
|
4
|
+
data.tar.gz: e076c8820a77e7ee86a5dcab2fe4f795fad9368788b97e96de42e91b1000eab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cf072d983562a79b62048aacb5242eb43c67317b604a74713cb2111d3790e664bcc8fbac7d6d6c21730982f574d3878227b9168ce82fea2fbd120da227fba09
|
7
|
+
data.tar.gz: 302a4cbadb70f86b53638ea670983bbde231095e9eb64747072f708ca934003a85794abe61338e3a63b5993ca9ffb269370f85504a3e1eab169687ee9a257eb9
|
data/lib/rails_param/param.rb
CHANGED
@@ -92,6 +92,9 @@ module RailsParam
|
|
92
92
|
begin
|
93
93
|
return nil if param.nil?
|
94
94
|
return param if (param.is_a?(type) rescue false)
|
95
|
+
if (param.is_a?(Array) && type != Array) || ((param.is_a?(Hash) || param.is_a?(ActionController::Parameters)) && type != Hash)
|
96
|
+
raise InvalidParameterError, "'#{param}' is not a valid #{type}"
|
97
|
+
end
|
95
98
|
return param if (param.is_a?(ActionController::Parameters) && type == Hash rescue false)
|
96
99
|
return Integer(param) if type == Integer
|
97
100
|
return Float(param) if type == Float
|
@@ -101,7 +104,12 @@ module RailsParam
|
|
101
104
|
return DateTime.parse(param) if type == DateTime
|
102
105
|
return Array(param.split(options[:delimiter] || ",")) if type == Array
|
103
106
|
return Hash[param.split(options[:delimiter] || ",").map { |c| c.split(options[:separator] || ":") }] if type == Hash
|
104
|
-
|
107
|
+
if type == TrueClass || type == FalseClass || type == :boolean
|
108
|
+
return false if /^(false|f|no|n|0)$/i === param.to_s
|
109
|
+
return true if /^(true|t|yes|y|1)$/i === param.to_s
|
110
|
+
|
111
|
+
raise ArgumentError
|
112
|
+
end
|
105
113
|
if type == BigDecimal
|
106
114
|
param = param.delete('$,').strip.to_f if param.is_a?(String)
|
107
115
|
return BigDecimal.new(param, (options[:precision] || DEFAULT_PRECISION))
|
data/lib/rails_param/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Blanco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: 1.3.6
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.7.7
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Parameter Validation and Type Coercion for Rails
|