strip_attributes 1.0.1 → 1.0.2
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.
data/lib/strip_attributes.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
module ActiveModel::Validations::HelperMethods
|
2
4
|
# Strips whitespace from model fields and converts blank values to nil.
|
3
5
|
def strip_attributes(options = nil)
|
4
6
|
before_validation do |record|
|
@@ -17,7 +19,9 @@ module StripAttributes
|
|
17
19
|
warn "[DEPRECATION] `strip_attributes!` is deprecated. Please use `strip_attributes` (non-bang method) instead."
|
18
20
|
strip_attributes(options)
|
19
21
|
end
|
22
|
+
end
|
20
23
|
|
24
|
+
module StripAttributes
|
21
25
|
# Necessary because Rails has removed the narrowing of attributes using :only
|
22
26
|
# and :except on Base#attributes
|
23
27
|
def self.narrow(attributes, options)
|
@@ -36,5 +40,3 @@ module StripAttributes
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
39
|
-
|
40
|
-
require "strip_attributes/active_model"
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strip_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-28 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70229912860820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70229912860820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &70229912858740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70229912858740
|
36
36
|
description: StripAttributes automatically strips all ActiveRecord model attributes
|
37
37
|
of leading and trailing whitespace before validation. If the attribute is blank,
|
38
38
|
it strips the value to nil.
|
@@ -42,7 +42,6 @@ executables: []
|
|
42
42
|
extensions: []
|
43
43
|
extra_rdoc_files: []
|
44
44
|
files:
|
45
|
-
- lib/strip_attributes/active_model.rb
|
46
45
|
- lib/strip_attributes/shoulda/macros.rb
|
47
46
|
- lib/strip_attributes/shoulda.rb
|
48
47
|
- lib/strip_attributes/version.rb
|
@@ -63,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
62
|
version: '0'
|
64
63
|
segments:
|
65
64
|
- 0
|
66
|
-
hash:
|
65
|
+
hash: 4215659657978427151
|
67
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
67
|
none: false
|
69
68
|
requirements:
|
@@ -72,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
71
|
version: '0'
|
73
72
|
segments:
|
74
73
|
- 0
|
75
|
-
hash:
|
74
|
+
hash: 4215659657978427151
|
76
75
|
requirements: []
|
77
76
|
rubyforge_project: strip_attributes
|
78
77
|
rubygems_version: 1.8.10
|