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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50b0c13f9e3c5697ffe2103ce08be27f4f647d04
4
- data.tar.gz: 2d29e0b13db351bfb7149b8a503995ec76ff1ec0
3
+ metadata.gz: 51f285cee8313b61091d5a50a53db46f7cc1b1d0
4
+ data.tar.gz: 97d3a518b97e27bc1b88b1c6a284761294985509
5
5
  SHA512:
6
- metadata.gz: 5b2cb7add33324eb6368ed684116d7b9e08d045e59efcd1e70ad9fe9bed2856f06c84401902ff81ba254b4d3d15478cd77ad1b1ed63b1c02ab1a78df731e5225
7
- data.tar.gz: 5456a73dbb05f9a45d676d251ce1082034946e0a3c56ed3394b6c59597ee64687f032fd743673ebaa09b7e25840bd43a412d1abdf66a7de6387e09ec678cef49
6
+ metadata.gz: 7eb43ccae8429f25005c3dde06c4b1fe0c46d66df96ec107066129b49aedb728b2e9ecbf4a1c0ec084f0da5cb911d7aded13a959ff9aa7994e1cc20a30c1ab84
7
+ data.tar.gz: 108b16fdeda54aa27e3989b79012073632a305058808671954ad86bc95719b99bf3914b57ab253dada81efb7a16c91821bf9e9ca954f4a2bd6f7380e000ed9be
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.0
2
+ - Remove Rails 3 support
3
+
1
4
  ## 0.2.3
2
5
  - Change execution context of validator block
3
6
  - Fix a development dependencies problem
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
- respond_with Recipe.create(params.slice(:name, :type))
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
- before_filter only: action_name do
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
@@ -1,3 +1,3 @@
1
1
  module WeakParameters
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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", ">= 3.2.11"
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.2.3
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-01-29 00:00:00.000000000 Z
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: 3.2.11
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: 3.2.11
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: autodoc
29
29
  requirement: !ruby/object:Gem::Requirement