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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d84fd4bf309d1033e2c8192fb33240efbe49481c
4
- data.tar.gz: ca19af6df7e37a423d1ad648b3078d296a249882
3
+ metadata.gz: c887dc202091783c97377901e8824127abc0273c
4
+ data.tar.gz: e1325595e3823ee66ac49c704379974e48cdf54a
5
5
  SHA512:
6
- metadata.gz: a8574c49f9a50508728969a4f75a4e968a239c0a22faebcae4375542885fd7a24dc736c29d1c3c1e3870641ce1d78fa629c573950bea909bb63f9627ee6161f6
7
- data.tar.gz: 09ee405c1a72ca1474e63572d8d6f999e8fbb288105e3263eb4b6b45f03187fd1488e01ef8341af1cd111dc99eec8134e12b515cd49ca4e763236ef408024ac7
6
+ metadata.gz: 8b8745cc672d751d27290f301ca5e5eeb48abdf685f7589b98c68a8b1d652b742b0f25ec399a0c9a55449801994a9c07f0750b5c189b16c65260a84cad0e8d61
7
+ data.tar.gz: ddd49c3dec293ba938911013ce3e24d4183e0dd3aded7a3f731cb186bfab9e984319c0256acbbc50cbc2809cd0d20639ed5b6fd92ad01e5e5fa534a2cb642a3c
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/SPBTV/allowed_params.svg?branch=master)](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
- validate :id, presence: true
39
- validate :name, presence: true
40
- validate :position, inclusion: { in: %w(manager developer) }
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
 
@@ -2,4 +2,6 @@ require 'allowed_params/validator_builder'
2
2
  require 'allowed_params/helper'
3
3
 
4
4
  module AllowedParams
5
+ include ActiveSupport::Configurable
6
+ config.allowed_params = []
5
7
  end
@@ -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 validate(name, options = {})
10
+ def validates(name, options = {})
14
11
  @params[name] = options
15
12
  end
16
13
 
@@ -1,3 +1,3 @@
1
1
  module AllowedParams
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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.3
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-06-20 00:00:00.000000000 Z
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: