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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 54219a64d62205a5f7b5225701e1063f00f6154f
4
- data.tar.gz: fcd54cba013965daeef08f4a6e3a8d857f38f2ba
2
+ SHA256:
3
+ metadata.gz: cb22b1fb5c98209fe81621c7f50152b17f2b0d5458d72c654da4b860d51059f0
4
+ data.tar.gz: ff6231049acb0905983ca99936e7e53c7122b8003dcb1c9fb04a77cb72bc9af8
5
5
  SHA512:
6
- metadata.gz: 4f1af4bd2b056774b5e0650744ca036adda1e5c63c0a4c02241e498ef1b36396a3cf01bf4aa7dbe62ac791d31182f3f3ab41771e65df963fef8b6b8f7ef16bb7
7
- data.tar.gz: b245fe4a9da12687ba89a49fa6f5912c2e3d5285298529a5059f4cd596d491ffe5b71cb13e575d80966e2e2ff22564e5a0c04eff45bffe0bfe5a8bdd8e02d79a
6
+ metadata.gz: a92756b7818f80ac3b68cf18e11ebcbd0e1ca7b5a3ca43b9e9864b10770c3a613597e8bde50c22d2709485977c9c35fbd1026c607c03ed3452c20b56b729739a
7
+ data.tar.gz: 1d41ef873c24d42fa8bf5b54a1612d424d5353049725b25b1e4678baaebb244f3e54415ba1d5a26deddb9f3d659c2482fe6ad93ef89e4cc090e95dabbe3ebb7e
@@ -4,3 +4,4 @@ require 'action_pack'
4
4
  require 'strong_parameters' if ActionPack::VERSION::MAJOR == 3
5
5
  require 'stronger_parameters/parameters'
6
6
  require 'stronger_parameters/constraints'
7
+ require 'stronger_parameters/controller_support/permitted_parameters'
@@ -9,6 +9,10 @@ module StrongerParameters
9
9
  @limit = limit
10
10
  end
11
11
 
12
+ def value(*)
13
+ raise NotImplementedError
14
+ end
15
+
12
16
  def ==(other)
13
17
  super && limit == other.limit
14
18
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rubocop:disable Style/DateTime
2
3
  require 'stronger_parameters/constraint'
3
4
 
4
5
  module StrongerParameters
@@ -14,3 +15,4 @@ module StrongerParameters
14
15
  end
15
16
  end
16
17
  end
18
+ # rubocop:enable Style/DateTime
@@ -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
- InvalidValue.new(v, "must be a hash")
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)
@@ -27,7 +27,7 @@ module StrongerParameters
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && maximum_length == other.maximum_length
30
+ super && maximum_length == other.maximum_length && minimum_length == other.minimum_length
31
31
  end
32
32
  end
33
33
  end
@@ -54,11 +54,11 @@ module StrongerParameters
54
54
 
55
55
  def permitted_parameters_for(action)
56
56
  unless for_action = permit_parameters[action]
57
- location = instance_method(action).source_location
58
- raise(
59
- KeyError,
60
- "Action #{action} for #{self} does not have any permitted parameters (#{location.join(":")})"
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
- attr_accessor :value, :message
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
- attr_accessor :key, :value
13
+ attr_reader :key, :value
14
14
 
15
15
  def initialize(invalid_value, key)
16
16
  @value = invalid_value.value
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module StrongerParameters
3
- VERSION = '2.9.1'
3
+ VERSION = '2.10.0'
4
4
  end
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.9.1
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: 2017-05-25 00:00:00.000000000 Z
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.4.5.1
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