stronger_parameters 2.4.0 → 2.5.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
2
  SHA1:
3
- metadata.gz: c37ab40f918773aa2b8dbdd1cf46f9bd63f36810
4
- data.tar.gz: d826e3897f34550419ab12c0016ead32473bd3ba
3
+ metadata.gz: e87d6cc0e6f6878f529537e78e3958cdd708bd6e
4
+ data.tar.gz: 5c898efbcaf23d4f263e2f96cb2bc9694acc849e
5
5
  SHA512:
6
- metadata.gz: 6e563a61a7e101b634d04cf8f6872aeb0b70e71617d85727017b4bcbadc847c8978c2392d38aa315506437bcfe59d6504ccd0d9c9f059b94c8968c5a3906b18e
7
- data.tar.gz: 5ba72f87eb60a35741e462c03a295302dfbc681ed50489c9a988969deb15b19730fb6cd0b986533d11152241862fb203ce97ca0201ba30436f84cf1d90272cad
6
+ metadata.gz: 4e8a57b30635864df2e97eaddffa9562573aa1c3e8d81620dcbeb439a19f4ebaf84905908ef8ed12803e36ca14b3c6d5737a11c14ce41486c6ddf1b6df29bd2b
7
+ data.tar.gz: a668ec3302be6dff0d420cc4e830c23b4e0a447a05068b63365828b8f28cb7583b5453bab0e8a0031f39203a36c278bf43900e676a90d868306f558a76185423
@@ -2,7 +2,7 @@ require 'stronger_parameters/constraints'
2
2
 
3
3
  module StrongerParameters
4
4
  class BooleanConstraint < Constraint
5
- TRUE_VALUES = [true, 'true', '1', 1].freeze
5
+ TRUE_VALUES = [true, 'true', '1', 1, 'on'].freeze
6
6
  FALSE_VALUES = [false, 'false', '0', 0].freeze
7
7
 
8
8
  def value(v)
@@ -9,9 +9,13 @@ module StrongerParameters
9
9
  end
10
10
 
11
11
  def value(v)
12
- if v.is_a?(Hash)
12
+ case
13
+ when v.is_a?(Hash)
13
14
  return ActionController::Parameters.new(v).permit! if constraints.nil?
14
15
  return ActionController::Parameters.new(v).permit(constraints)
16
+ when ActionPack::VERSION::MAJOR >= 5 && v.is_a?(ActionController::Parameters)
17
+ return v.permit! if constraints.nil?
18
+ return v.permit(constraints)
15
19
  end
16
20
 
17
21
  InvalidValue.new(v, "must be a hash")
@@ -15,7 +15,8 @@ module StrongerParameters
15
15
  extend ActiveSupport::Concern
16
16
 
17
17
  included do
18
- alias_method_chain :hash_filter, :stronger_parameters
18
+ alias_method :hash_filter_without_stronger_parameters, :hash_filter
19
+ alias_method :hash_filter, :hash_filter_with_stronger_parameters
19
20
  cattr_accessor :action_on_invalid_parameters, :instance_accessor => false
20
21
  cattr_accessor :allow_nil_for_everything, :instance_accessor => false
21
22
  end
@@ -172,7 +173,7 @@ module StrongerParameters
172
173
 
173
174
  included do
174
175
  rescue_from(StrongerParameters::InvalidParameter) do |e|
175
- render :text => "Invalid parameter: #{e.key} #{e.message}", :status => :bad_request
176
+ render (ActiveSupport::VERSION::MAJOR < 5 ? :text : :plain) => "Invalid parameter: #{e.key} #{e.message}", :status => :bad_request
176
177
  end
177
178
  end
178
179
  end
@@ -1,3 +1,3 @@
1
1
  module StrongerParameters
2
- VERSION = '2.4.0'
2
+ VERSION = '2.5.0'
3
3
  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.4.0
4
+ version: 2.5.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: 2015-09-22 00:00:00.000000000 Z
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,16 +154,22 @@ dependencies:
154
154
  name: actionpack
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">"
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '3.2'
160
+ - - "<"
158
161
  - !ruby/object:Gem::Version
159
- version: '3'
162
+ version: '5.1'
160
163
  type: :runtime
161
164
  prerelease: false
162
165
  version_requirements: !ruby/object:Gem::Requirement
163
166
  requirements:
164
- - - ">"
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '3.2'
170
+ - - "<"
165
171
  - !ruby/object:Gem::Version
166
- version: '3'
172
+ version: '5.1'
167
173
  description:
168
174
  email:
169
175
  - mick@zendesk.com
@@ -211,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
217
  version: '0'
212
218
  requirements: []
213
219
  rubyforge_project:
214
- rubygems_version: 2.2.2
220
+ rubygems_version: 2.4.5.1
215
221
  signing_key:
216
222
  specification_version: 4
217
223
  summary: Type checking and type casting of parameters for Action Pack