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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8cbf1f2bda303ead2066ddf49597a4af8b276ced
4
- data.tar.gz: c403d8ad4dafd5a1e014e8e8a0b10417e69badcc
2
+ SHA256:
3
+ metadata.gz: 78f71c8a36c9b2fc080a205733b8eef0d89a04db299ed3703bb333e08d00c8de
4
+ data.tar.gz: e076c8820a77e7ee86a5dcab2fe4f795fad9368788b97e96de42e91b1000eab4
5
5
  SHA512:
6
- metadata.gz: 9c509598a1dda1c1fe0a1276fe957c3259862ac9430b3b6302926ab4aecf26636eb6de0d07f3901e8f7ca6aa8ab1c3b1ea61c75af341a4a495bf6c6554b63505
7
- data.tar.gz: 7b2c56eff184db82d4497a46b203155c077bfb625178de27b6b38a5a8bc9947a088d29468d889d0ec0fccbeda28ebdfc853f73b4f4023d7170a0eb34dba68e86
6
+ metadata.gz: 6cf072d983562a79b62048aacb5242eb43c67317b604a74713cb2111d3790e664bcc8fbac7d6d6c21730982f574d3878227b9168ce82fea2fbd120da227fba09
7
+ data.tar.gz: 302a4cbadb70f86b53638ea670983bbde231095e9eb64747072f708ca934003a85794abe61338e3a63b5993ca9ffb269370f85504a3e1eab169687ee9a257eb9
@@ -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
- return (/^(false|f|no|n|0)$/i === param.to_s ? false : (/^(true|t|yes|y|1)$/i === param.to_s ? true : (raise ArgumentError))) if type == TrueClass || type == FalseClass || type == :boolean
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))
@@ -1,3 +1,3 @@
1
1
  module RailsParam #:nodoc
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
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.0
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: 2017-04-12 00:00:00.000000000 Z
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.5.1
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