moderate_parameters 0.3.2 → 0.3.3

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
  SHA256:
3
- metadata.gz: ba33050049dd8c5032eae5d421dd37b9e6aab9bd399f3c414fcd44f3659932bd
4
- data.tar.gz: 1f1d1d4401fa487a322e56ce1654b0943df2c114807791248222c90e463e6566
3
+ metadata.gz: eadf86f5451aa4174775854ab8a06f333df6f8a1a5a488b2243c918c8dcd3b0e
4
+ data.tar.gz: e5fd0011f7e56fd2962048b164be839ff3b6884816984376eb2b645ab796cf73
5
5
  SHA512:
6
- metadata.gz: 941f550a839d2d6bd48321cdb9627eab93226dc5d655c009f4073f97d6a77f4fc6d1945803143b99314fced7d341fe1604f78a11488ffd4e94ccdc92f3925777
7
- data.tar.gz: 5dbd1d0c60870bd8b0aa3749fcd685a5599d029c40797cc9f988141458df8b7b0a834c1340e0c1567788f44bbe7f855f122f227b65d0162167a7dba00a41c837
6
+ metadata.gz: c6466402a390cc33148e0aed8227136af9ce60938d2f393d74c53e56814febae9802de2d9f0d407b76aaf4787b55237fe06cf7332b79e7b822aae84aae943e04
7
+ data.tar.gz: 1a56422b48b5111e4616310acf87f254ba899637696e52d8951df9e1eaf7462663184546f061689b08f31483a0bb30a969405e1c46a406e89211499b5b197988
data/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  By [Hint.io](https://hint.io)
7
7
 
8
+ [![Gem Version](https://badge.fury.io/rb/moderate_parameters.svg)](https://badge.fury.io/rb/moderate_parameters) [![CircleCI](https://circleci.com/gh/hintmedia/moderate_parameters.svg?style=svg)](https://circleci.com/gh/hintmedia/moderate_parameters) [![Maintainability](https://api.codeclimate.com/v1/badges/4971eb01d5bd98dbac8b/maintainability)](https://codeclimate.com/github/hintmedia/moderate_parameters/maintainability)
9
+
8
10
  In our experience with [UpgradeRails](https://www.upgraderails.com), the migration from [protected_attributes](https://github.com/rails/protected_attributes) to [strong_parameters](https://api.rubyonrails.org/classes/ActionController/StrongParameters.html) can leave more questions than answers. It can be difficult to determine what data is originating from within the app and what is coming from the internet.
9
11
 
10
12
  Moderate Parameters is a set of tools providing logging of data sources in the controller by extending `ActionController::Parameters` functionality.
@@ -111,7 +113,7 @@ end
111
113
 
112
114
  We can then hit submit data from the form at `/people/new` and see that no new lines are added to the `moderate_parameters.log` file.
113
115
 
114
- This means that we can remove `moderate_parameters` and move to using `permit` as a part of `strong_parameters`:
116
+ This means that we can remove `moderate_parameters` and move to using `permit` as the final migration step of `strong_parameters`:
115
117
 
116
118
  ```ruby
117
119
  class PeopleController < ActionController::Base
@@ -129,6 +131,17 @@ class PeopleController < ActionController::Base
129
131
  end
130
132
  ```
131
133
 
134
+ It is only _**AFTER**_ this final step of the `strong_parameters` migration has been completed that you can safely remove the `protected_attributes` line in the model:
135
+
136
+ ```ruby
137
+ class Person < ActiveRecord::Base
138
+ # attr_accessible :name, :age, :height
139
+
140
+ . . .
141
+
142
+ end
143
+ ```
144
+
132
145
  ## Contributing
133
146
 
134
147
  Bug reports and pull requests are welcome on GitHub at https://github.com/hintmedia/moderate_parameters. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -47,6 +47,12 @@ module ModerateParameters
47
47
  end
48
48
  end
49
49
 
50
+ def array_of_permitted_scalars?(value)
51
+ if value.is_a?(Array) && value.all? { |element| permitted_scalar?(element) }
52
+ yield value
53
+ end
54
+ end
55
+
50
56
  def non_scalar?(value)
51
57
  value.is_a?(Array) || value.is_a?(Parameters)
52
58
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ModerateParameters
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moderate_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Boe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack