fast_attributes 0.5.1 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a1d80b95f685bd4f784b487c2f8f77fa32ac70e
4
- data.tar.gz: 51b53422f3dd3c82a67e1ec07fc29102bfca6393
3
+ metadata.gz: 7b5f750706150406ddcaa4787a9dece903c0c392
4
+ data.tar.gz: 3c365ac0da073679f56adffa0af47ff96ac8105c
5
5
  SHA512:
6
- metadata.gz: a7253c0f32e55877e353dd9faf04812f49663b4f45eb447e53f5f8879119ccf9348a0cd689ce01236ffc338d628ccd504ced69a56e8177b4f1d43eb7668ce1c9
7
- data.tar.gz: 7ed3cc4165363858a85707ba2596444921989715ee767a3d41cfd530954469201fe51db2bb6c17ba247f7a859c54827f24df009e3b9778dccc4dd392aa98c497
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 = {})
@@ -1,3 +1,3 @@
1
1
  module FastAttributes
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -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.1
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-16 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler