rails_param 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_param/param_evaluator.rb +4 -4
- data/lib/rails_param/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b32fa09a116632065ef4726382ba7f10a83c9cdcb56f8b15c75fcd9fc2577667
|
4
|
+
data.tar.gz: 97b1d1485ba6abec6e87eee788bd3899702f5b0af565f6b159606107276c210f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae6601c59348ef2f899aca2e5d54613882028134fd7fbe0757bd0bee507b873eadf7d2e488b3010c401faea06ba9fdee23992274416a70f6711f824aef9d6f65
|
7
|
+
data.tar.gz: 4602f52aae2d9f625f8464cbaa2de07baf658e7112e9185fcb9e917787c97d6095dad62cbf4483faedb77dc281d6b5af2a621a90993c7e0033cdc9d6b101f5d9
|
@@ -12,7 +12,7 @@ module RailsParam
|
|
12
12
|
return unless params.include?(name) || check_param_presence?(options[:default]) || options[:required]
|
13
13
|
|
14
14
|
parameter_name = @context ? "#{@context}[#{name}]" : name
|
15
|
-
coerced_value = coerce(params[name], type, options)
|
15
|
+
coerced_value = coerce(parameter_name, params[name], type, options)
|
16
16
|
|
17
17
|
parameter = RailsParam::Parameter.new(
|
18
18
|
name: parameter_name,
|
@@ -36,7 +36,7 @@ module RailsParam
|
|
36
36
|
recurse_on_parameter(parameter, &block) if block_given?
|
37
37
|
|
38
38
|
# apply transformation
|
39
|
-
parameter.transform if
|
39
|
+
parameter.transform if options[:transform]
|
40
40
|
|
41
41
|
# validate
|
42
42
|
validate!(parameter)
|
@@ -73,14 +73,14 @@ module RailsParam
|
|
73
73
|
!param.nil?
|
74
74
|
end
|
75
75
|
|
76
|
-
def coerce(param, type, options = {})
|
76
|
+
def coerce(param_name, param, type, options = {})
|
77
77
|
begin
|
78
78
|
return nil if param.nil?
|
79
79
|
return param if (param.is_a?(type) rescue false)
|
80
80
|
|
81
81
|
Coercion.new(param, type, options).coerce
|
82
82
|
rescue ArgumentError, TypeError
|
83
|
-
raise InvalidParameterError
|
83
|
+
raise InvalidParameterError.new("'#{param}' is not a valid #{type}", param: param_name)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
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: 1.3.
|
4
|
+
version: 1.3.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: 2023-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|