coercion 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/lib/coercion.rb +11 -6
- data/lib/coercion/railtie.rb +2 -1
- metadata +4 -3
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2011 Tyler Hunt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/coercion.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
-
require 'coercion/railtie'
|
1
|
+
require 'coercion/railtie' if defined?(::Rails::Railtie)
|
2
2
|
|
3
3
|
module Coercion
|
4
|
-
|
5
|
-
|
6
|
-
value.
|
7
|
-
|
4
|
+
module CoerceEmptyStringsToNil
|
5
|
+
def write_attribute(attr_name, value)
|
6
|
+
value = nil if value.is_a?(String) && value.empty?
|
7
|
+
super
|
8
8
|
end
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
module StripStrings
|
12
|
+
def write_attribute(attr_name, value)
|
13
|
+
value.strip! if value.is_a?(String)
|
14
|
+
super
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
data/lib/coercion/railtie.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coercion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tyler Hunt
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
|
77
77
|
files:
|
78
|
+
- LICENSE
|
78
79
|
- lib/coercion/railtie.rb
|
79
80
|
- lib/coercion.rb
|
80
81
|
has_rdoc: true
|