fast_attributes 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +19 -0
- data/lib/fast_attributes/type_cast.rb +1 -1
- data/lib/fast_attributes/version.rb +1 -1
- data/spec/fast_attributes/type_cast_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5f750706150406ddcaa4787a9dece903c0c392
|
4
|
+
data.tar.gz: 3c365ac0da073679f56adffa0af47ff96ac8105c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 132afa531200fe1b2ded5ae0a17b0d9d0e232f6dd7d3216d55281e52e19c0ecec322f861c05b8aa353fb6c3cc52c9efc76716b173a1ea64d040508d9fcf66f99
|
7
|
+
data.tar.gz: 38ef6165ba6fe8f57b5d8c67974671b9de4b5990b5d0d5176c79226432560e5deb85fd33bb1f073ef77f237b7ba8bf2088319547ad40c21a4752fe55573e603e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
**0.5.2 (July 18, 2014)**
|
2
|
+
* Throw proper exception when type casting function is not defined
|
3
|
+
|
4
|
+
**0.5.1 (July 16, 2014)**
|
5
|
+
* Fix `BigDecimal` type casting. It threw an exception when input value was `Integer` or `Float`
|
6
|
+
|
1
7
|
**0.5.0 (July 16, 2014)**
|
2
8
|
* Allow to control any switch statements during typecasting using new DSL.
|
3
9
|
|
data/README.md
CHANGED
@@ -143,6 +143,25 @@ square.size
|
|
143
143
|
# => [5, 5]
|
144
144
|
```
|
145
145
|
|
146
|
+
Method `FastAttributes.set_type_casting` generates the following code:
|
147
|
+
```ruby
|
148
|
+
FastAttributes.set_type_casting String, 'String(%s)'
|
149
|
+
# case %s
|
150
|
+
# when nil then nil
|
151
|
+
# when String then %s
|
152
|
+
# else String(%s)
|
153
|
+
# end
|
154
|
+
```
|
155
|
+
|
156
|
+
If you need to conrol the whole type casting process, you can use the following DSL:
|
157
|
+
```ruby
|
158
|
+
FastAttributes.type_cast String do # case String
|
159
|
+
from 'nil', to: 'nil' # when nil then nil
|
160
|
+
from 'String', to: '%s' # when String then %s
|
161
|
+
otherwise 'String(%s)' # else String(%s)
|
162
|
+
end # end
|
163
|
+
```
|
164
|
+
|
146
165
|
## Extensions
|
147
166
|
* [fast_attributes-uuid](https://github.com/applift/fast_attributes-uuid) - adds support of `UUID` to `fast_attributes`
|
148
167
|
|
@@ -5,7 +5,7 @@ module FastAttributes
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@if_conditions = []
|
8
|
-
@else_condition = %q(raise UnknownTypeCastingError, 'Type casting is not defined')
|
8
|
+
@else_condition = %q(raise FastAttributes::TypeCast::UnknownTypeCastingError, 'Type casting is not defined')
|
9
9
|
end
|
10
10
|
|
11
11
|
def from(condition, options = {})
|
@@ -7,7 +7,7 @@ describe FastAttributes::TypeCast do
|
|
7
7
|
describe 'without any conditions' do
|
8
8
|
it 'return exception' do
|
9
9
|
expect(type_cast.template.gsub(' ', '')).to eq <<-EOS.gsub(' ', '').chomp
|
10
|
-
raise UnknownTypeCastingError, 'Type casting is not defined'
|
10
|
+
raise FastAttributes::TypeCast::UnknownTypeCastingError, 'Type casting is not defined'
|
11
11
|
EOS
|
12
12
|
end
|
13
13
|
end
|
@@ -23,7 +23,7 @@ describe FastAttributes::TypeCast do
|
|
23
23
|
when nil
|
24
24
|
nil
|
25
25
|
else
|
26
|
-
raise UnknownTypeCastingError, 'Type casting is not defined'
|
26
|
+
raise FastAttributes::TypeCast::UnknownTypeCastingError, 'Type casting is not defined'
|
27
27
|
end
|
28
28
|
EOS
|
29
29
|
end
|
@@ -46,7 +46,7 @@ describe FastAttributes::TypeCast do
|
|
46
46
|
when Integer
|
47
47
|
Integer(%s)
|
48
48
|
else
|
49
|
-
raise UnknownTypeCastingError, 'Type casting is not defined'
|
49
|
+
raise FastAttributes::TypeCast::UnknownTypeCastingError, 'Type casting is not defined'
|
50
50
|
end
|
51
51
|
EOS
|
52
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kostiantyn Stepaniuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|