weak_parameters 0.1.2 → 0.1.3
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/CHANGELOG.md +40 -0
- data/README.md +16 -0
- data/lib/weak_parameters/version.rb +1 -1
- data/lib/weak_parameters.rb +8 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2729c50cf6a7bf575ece702332a9c49777844d2
|
4
|
+
data.tar.gz: d0a8b974f3ec852ac01ad7b5e0cc9a2693235297
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83dd640de0cd2d2eda683ac2c5d96b0dc995e678dbc11f248c0f787af5e33bb8332faad2c791d2293ddf55738d68cea669b12a5e464657f96d5afd74ee26294b
|
7
|
+
data.tar.gz: cc89b87958e71b96427ff27360d4a5c396b8eb5d4a088b89893352bdbc171c541a2239e9c2879c4276a95e534d76689222007bd97613f7fc5eadabee080051b1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## 0.1.3
|
2
|
+
* Don't directly touch AC::Base, but do it via AS.on_load
|
3
|
+
|
4
|
+
## 0.1.2
|
5
|
+
* Add `:handler` option to customize failure behavior
|
6
|
+
* Fix bug around `float` validator with block
|
7
|
+
|
8
|
+
## 0.1.1
|
9
|
+
* Add `any` validator
|
10
|
+
|
11
|
+
## 0.1.0
|
12
|
+
* Add type checking to `string` validator
|
13
|
+
|
14
|
+
## 0.0.9
|
15
|
+
* Improve error message
|
16
|
+
|
17
|
+
## 0.0.8
|
18
|
+
* Add block support to all validators
|
19
|
+
* Add `float` validator
|
20
|
+
|
21
|
+
## 0.0.7
|
22
|
+
* Fix `integer` validator bug
|
23
|
+
|
24
|
+
## 0.0.6
|
25
|
+
* Change value handling in `:only` & `:except` checking
|
26
|
+
|
27
|
+
## 0.0.5
|
28
|
+
* Add `:only` & `:except` options
|
29
|
+
|
30
|
+
## 0.0.4
|
31
|
+
* Fix stored controller name for namespaced controller
|
32
|
+
|
33
|
+
## 0.0.3
|
34
|
+
* Fix type name bug
|
35
|
+
|
36
|
+
## 0.0.2
|
37
|
+
* Add `hash` & `boolean` validator
|
38
|
+
|
39
|
+
## 0.0.1
|
40
|
+
* Release the first version on 2013-06-07
|
data/README.md
CHANGED
@@ -8,6 +8,16 @@ gem "weak_parameters"
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
```ruby
|
11
|
+
class ApplicationController < ActionController::Base
|
12
|
+
protect_from_forgery
|
13
|
+
|
14
|
+
respond_to :json
|
15
|
+
|
16
|
+
rescue_from WeakParameters::ValidationError do
|
17
|
+
head 400
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
# WeakParameters provides `validates` class method to define validations.
|
12
22
|
class RecipesController < ApplicationController
|
13
23
|
validates :create do
|
@@ -46,6 +56,12 @@ irb(main):005:0> app.post "/recipes", name: "alice", type: "bob"
|
|
46
56
|
* string
|
47
57
|
* boolean (= 0, 1, false, true)
|
48
58
|
|
59
|
+
### Avilable options
|
60
|
+
* required
|
61
|
+
* only
|
62
|
+
* except
|
63
|
+
* handler
|
64
|
+
|
49
65
|
## Tips
|
50
66
|
WeakParameters.stats returns its validation metadata, and this is useful for auto-generating API documents.
|
51
67
|
With [autodoc](https://github.com/r7kamura/autodoc), you can auto-generate API documents with params information.
|
data/lib/weak_parameters.rb
CHANGED
@@ -49,6 +49,12 @@ module WeakParameters
|
|
49
49
|
hash[key] = ActiveSupport::HashWithIndifferentAccess.new
|
50
50
|
end
|
51
51
|
end
|
52
|
-
end
|
53
52
|
|
54
|
-
|
53
|
+
class Railties < ::Rails::Railtie
|
54
|
+
initializer 'weak_parameters' do
|
55
|
+
ActiveSupport.on_load :action_controller do
|
56
|
+
ActionController::Base.extend WeakParameters::Controller
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- CHANGELOG.md
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|