params_cleaner 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/params_cleaner.rb +6 -4
- metadata +5 -5
data/lib/params_cleaner.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
require "active_support/concern"
|
2
2
|
require "active_support/core_ext/hash/slice"
|
3
|
+
require "active_support/hash_with_indifferent_access"
|
3
4
|
|
4
5
|
module ParamsCleaner
|
5
6
|
extend ActiveSupport::Concern
|
6
7
|
|
7
|
-
VERSION = "0.1.
|
8
|
+
VERSION = "0.1.2"
|
8
9
|
|
9
10
|
def clean_params(root_params = params)
|
10
11
|
cleaned_params = root_params.map do |key, val|
|
11
|
-
if val.
|
12
|
-
clean_values = clean_params(val.slice(*self.class._allowed_params[key]))
|
12
|
+
if val.kind_of?(Hash)
|
13
|
+
clean_values = clean_params(val.slice(*self.class._allowed_params[key.to_sym]))
|
13
14
|
[key, clean_values]
|
14
15
|
else
|
15
16
|
[key, val]
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
Hash[cleaned_params]
|
20
|
+
cleaned_params_hash = Hash[cleaned_params]
|
21
|
+
HashWithIndifferentAccess.new(cleaned_params_hash)
|
20
22
|
end
|
21
23
|
|
22
24
|
module ClassMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: params_cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70285576499760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70285576499760
|
25
25
|
description: Rails mass assignment protection in the controller
|
26
26
|
email:
|
27
27
|
- drew@drewolson.org
|
@@ -44,7 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
44
|
version: '0'
|
45
45
|
segments:
|
46
46
|
- 0
|
47
|
-
hash:
|
47
|
+
hash: 4310871954395950718
|
48
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
segments:
|
55
55
|
- 0
|
56
|
-
hash:
|
56
|
+
hash: 4310871954395950718
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.8.15
|