weak_parameters 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +5 -3
- data/lib/weak_parameters/controller.rb +1 -1
- data/lib/weak_parameters/version.rb +1 -1
- data/weak_parameters.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f285cee8313b61091d5a50a53db46f7cc1b1d0
|
4
|
+
data.tar.gz: 97d3a518b97e27bc1b88b1c6a284761294985509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eb43ccae8429f25005c3dde06c4b1fe0c46d66df96ec107066129b49aedb728b2e9ecbf4a1c0ec084f0da5cb911d7aded13a959ff9aa7994e1cc20a30c1ab84
|
7
|
+
data.tar.gz: 108b16fdeda54aa27e3989b79012073632a305058808671954ad86bc95719b99bf3914b57ab253dada81efb7a16c91821bf9e9ca954f4a2bd6f7380e000ed9be
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -21,15 +21,16 @@ end
|
|
21
21
|
# WeakParameters provides `validates` class method to define validations.
|
22
22
|
class RecipesController < ApplicationController
|
23
23
|
validates :create do
|
24
|
-
string :name, required: true, except: ["charlie", "dave"]
|
25
|
-
integer :type, only: 1..3
|
24
|
+
string :name, required: true, except: ["charlie", "dave"], strong: true
|
25
|
+
integer :type, only: 1..3, strong: true
|
26
26
|
string :quantity do |value|
|
27
27
|
value =~ /\A\d+(?:\.\d+)g\z/
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def create
|
32
|
-
|
32
|
+
# pass the only parameters with strong option. like strong parameters.
|
33
|
+
respond_with Recipe.create(permitted_params)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
```
|
@@ -64,6 +65,7 @@ irb(main):005:0> app.post "/recipes", name: "alice", type: "bob"
|
|
64
65
|
* only
|
65
66
|
* except
|
66
67
|
* handler
|
68
|
+
* strong
|
67
69
|
|
68
70
|
## Tips
|
69
71
|
WeakParameters.stats returns its validation metadata, and this is useful for auto-generating API documents.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module WeakParameters
|
2
2
|
module Controller
|
3
3
|
def validates(action_name, &block)
|
4
|
-
|
4
|
+
before_action only: action_name do
|
5
5
|
validator = WeakParameters::Validator.new(self, &block)
|
6
6
|
WeakParameters.stats[params[:controller]][params[:action]] = validator
|
7
7
|
WeakParameters.stats[params[:controller]][params[:action]].validate
|
data/weak_parameters.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "rails", ">=
|
20
|
+
spec.add_dependency "rails", ">= 4.0.0"
|
21
21
|
spec.add_development_dependency "autodoc"
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
23
|
spec.add_development_dependency "pry-rails"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weak_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: autodoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|