stronger_parameters 2.9.1 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/stronger_parameters.rb +1 -0
- data/lib/stronger_parameters/constraints/comparison_constraints.rb +4 -0
- data/lib/stronger_parameters/constraints/date_time_constraint.rb +2 -0
- data/lib/stronger_parameters/constraints/hash_constraint.rb +7 -8
- data/lib/stronger_parameters/constraints/string_constraint.rb +1 -1
- data/lib/stronger_parameters/controller_support/permitted_parameters.rb +5 -5
- data/lib/stronger_parameters/errors.rb +2 -2
- data/lib/stronger_parameters/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: cb22b1fb5c98209fe81621c7f50152b17f2b0d5458d72c654da4b860d51059f0
|
4
|
+
data.tar.gz: ff6231049acb0905983ca99936e7e53c7122b8003dcb1c9fb04a77cb72bc9af8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a92756b7818f80ac3b68cf18e11ebcbd0e1ca7b5a3ca43b9e9864b10770c3a613597e8bde50c22d2709485977c9c35fbd1026c607c03ed3452c20b56b729739a
|
7
|
+
data.tar.gz: 1d41ef873c24d42fa8bf5b54a1612d424d5353049725b25b1e4678baaebb244f3e54415ba1d5a26deddb9f3d659c2482fe6ad93ef89e4cc090e95dabbe3ebb7e
|
data/lib/stronger_parameters.rb
CHANGED
@@ -10,15 +10,14 @@ module StrongerParameters
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def value(v)
|
13
|
-
if v.is_a?(Hash)
|
14
|
-
return ActionController::Parameters.new(v).permit! if constraints.nil?
|
15
|
-
return ActionController::Parameters.new(v).permit(constraints)
|
16
|
-
elsif ActionPack::VERSION::MAJOR >= 5 && v.is_a?(ActionController::Parameters)
|
17
|
-
return v.permit! if constraints.nil?
|
18
|
-
return v.permit(constraints)
|
19
|
-
end
|
13
|
+
return InvalidValue.new(v, "must be a hash") if !v.is_a?(Hash) && !v.is_a?(ActionController::Parameters)
|
20
14
|
|
21
|
-
|
15
|
+
v = ActionController::Parameters.new(v) if v.is_a?(Hash)
|
16
|
+
if constraints.nil?
|
17
|
+
v.permit!
|
18
|
+
else
|
19
|
+
v.permit(constraints)
|
20
|
+
end
|
22
21
|
end
|
23
22
|
|
24
23
|
def merge(other)
|
@@ -54,11 +54,11 @@ module StrongerParameters
|
|
54
54
|
|
55
55
|
def permitted_parameters_for(action)
|
56
56
|
unless for_action = permit_parameters[action]
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
)
|
57
|
+
# NOTE: there is no easy way to test this, so make sure to test with
|
58
|
+
# a real rails controller if you make changes.
|
59
|
+
message = "Action #{action} for #{self} does not have any permitted parameters"
|
60
|
+
message += " (#{instance_method(action).source_location.join(":")})" if method_defined?(action)
|
61
|
+
raise(KeyError, message)
|
62
62
|
end
|
63
63
|
return :skip if for_action == :skip
|
64
64
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module StrongerParameters
|
3
3
|
class InvalidValue
|
4
|
-
|
4
|
+
attr_reader :value, :message
|
5
5
|
|
6
6
|
def initialize(value, message)
|
7
7
|
@value = value
|
@@ -10,7 +10,7 @@ module StrongerParameters
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class InvalidParameter < StandardError
|
13
|
-
|
13
|
+
attr_reader :key, :value
|
14
14
|
|
15
15
|
def initialize(invalid_value, key)
|
16
16
|
@value = invalid_value.value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stronger_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
220
|
version: '0'
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.7.3
|
224
224
|
signing_key:
|
225
225
|
specification_version: 4
|
226
226
|
summary: Type checking and type casting of parameters for Action Pack
|