allowed_params 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/allowed_params.rb +2 -0
- data/lib/allowed_params/validator_builder.rb +1 -4
- data/lib/allowed_params/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c887dc202091783c97377901e8824127abc0273c
|
4
|
+
data.tar.gz: e1325595e3823ee66ac49c704379974e48cdf54a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b8745cc672d751d27290f301ca5e5eeb48abdf685f7589b98c68a8b1d652b742b0f25ec399a0c9a55449801994a9c07f0750b5c189b16c65260a84cad0e8d61
|
7
|
+
data.tar.gz: ddd49c3dec293ba938911013ce3e24d4183e0dd3aded7a3f731cb186bfab9e984319c0256acbbc50cbc2809cd0d20639ed5b6fd92ad01e5e5fa534a2cb642a3c
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://travis-ci.org/SPBTV/allowed_params)
|
2
|
+
|
1
3
|
# AllowedParams
|
2
4
|
|
3
5
|
## Installation
|
@@ -35,9 +37,9 @@ This gem provides filtering and validations of params
|
|
35
37
|
include AllowedParams::Helper
|
36
38
|
|
37
39
|
params whitelist: true do
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
validates :id, presence: true
|
41
|
+
validates :name, presence: true
|
42
|
+
validates :position, inclusion: { in: %w(manager developer) }
|
41
43
|
end
|
42
44
|
def update
|
43
45
|
# do the job
|
@@ -48,6 +50,7 @@ This gem provides filtering and validations of params
|
|
48
50
|
|
49
51
|
This will validate listed params and raise `AllowedParams::ValidationError` in case of invalid value.
|
50
52
|
All other params are not allowed, and `AllowedParams::NotAllowedError` will be raised if present.
|
53
|
+
You can use any of [ActiveModel::Validations](http://api.rubyonrails.org/classes/ActiveModel/Validations.html)' validators.
|
51
54
|
|
52
55
|
To allow params on all controllers:
|
53
56
|
|
data/lib/allowed_params.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
require_relative 'model'
|
2
2
|
|
3
3
|
module AllowedParams
|
4
|
-
include ActiveSupport::Configurable
|
5
|
-
config.allowed_params = []
|
6
|
-
|
7
4
|
class ValidatorBuilder
|
8
5
|
def initialize(controller)
|
9
6
|
@controller = controller
|
10
7
|
@params = {}
|
11
8
|
end
|
12
9
|
|
13
|
-
def
|
10
|
+
def validates(name, options = {})
|
14
11
|
@params[name] = options
|
15
12
|
end
|
16
13
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allowed_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -94,4 +94,3 @@ signing_key:
|
|
94
94
|
specification_version: 4
|
95
95
|
summary: Filter params on rails controllers
|
96
96
|
test_files: []
|
97
|
-
has_rdoc:
|