tainbox 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +11 -0
- data/lib/tainbox/type_converter.rb +11 -1
- data/lib/tainbox/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e918789c23fdf76d107321cefc24c818644c5a1
|
4
|
+
data.tar.gz: f38d5d363ecd93f1215a92f9628f4e8c76845a48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55697c48d4e0f1eed0de539a8a1d7561855747bd0ed0fbafc0d86a9a22491120cf4e72f5abd5f77b8a875fc7684ee716ccd3534f20748a330551b422c644a01c
|
7
|
+
data.tar.gz: 1b15674854681954ad2501be306b7e0af03d5e75d661a6dd8dbaed9295fa7fdb29f842d704457016aa90ed430e89e6fb6bcfd424bf3fdc336e6d5cf5155a7f5e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -95,6 +95,17 @@ All converters return nil if conversion could not be made.
|
|
95
95
|
- Time
|
96
96
|
- Boolean
|
97
97
|
|
98
|
+
### String type converter options
|
99
|
+
|
100
|
+
String converter supports additional options: `strip` and `downcase` which strip and downcase
|
101
|
+
input attribute values respectively
|
102
|
+
|
103
|
+
Example:
|
104
|
+
|
105
|
+
``` ruby
|
106
|
+
attribute :name, String, strip: true, downcase: true
|
107
|
+
```
|
108
|
+
|
98
109
|
### Custom type converters
|
99
110
|
|
100
111
|
You can define a custom type converter like so:
|
@@ -41,7 +41,17 @@ end
|
|
41
41
|
|
42
42
|
Tainbox.define_converter(String) do
|
43
43
|
strip = options.fetch(:strip, false)
|
44
|
-
|
44
|
+
downcase = options.fetch(:downcase, false)
|
45
|
+
result = value.to_s
|
46
|
+
|
47
|
+
result = result.strip if strip
|
48
|
+
|
49
|
+
if downcase
|
50
|
+
result = result.mb_chars if result.respond_to?(:mb_chars)
|
51
|
+
result = result.downcase
|
52
|
+
end
|
53
|
+
|
54
|
+
result
|
45
55
|
end
|
46
56
|
|
47
57
|
Tainbox.define_converter(Symbol) do
|
data/lib/tainbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tainbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Gubitskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.4.6
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Tainbox is a utility gem that can be used to inject attributes into ruby
|