active_type 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7a8aaa4de25bb39e76fe2f9d62ee07650ab25c2
4
- data.tar.gz: e9f689b6b22a2e253f6c7d191bf6ae9b757c149f
3
+ metadata.gz: 2f6709aa6a9fb26d216bd6824523b35af47d6e53
4
+ data.tar.gz: c4699de79bcfca007fd56d7f513916fccb424fbb
5
5
  SHA512:
6
- metadata.gz: 5306d05e6793c5656ee6afebd49bc70b3579667f94cee32f23a3f5ac834bc920fd48bc278c730a114493298fc173e0f43a72188681da896cf3b6af92e43991c8
7
- data.tar.gz: bd0bfbe15cfe7dc610feaf52e75246ad28ea93419e1fc7e90589b3f9f57736f442a6558d0a8d4752c3d060cd20299bd2ee86cf0cf5841ba48c06b6bf5746bb91
6
+ metadata.gz: 4285b28839f7e1ba7a10c807cdc0cb497d46bdedfa5f621e4ec699787e564145d3e2819134dc8250739d18e7de6aa3eea33e9e83989446b0f031d46611754e04
7
+ data.tar.gz: 139b82919f9a75396ac3c15174d946aa5e12e9a14dea25fe8a24a6b14bb334bbec090ab5a5903c538ff34004cf7ca878cb7e6ceab6648af5390d725e0503b8cd
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -36,6 +36,8 @@ module ActiveType
36
36
  else
37
37
  super
38
38
  end
39
+ when nil
40
+ value
39
41
  else
40
42
  super
41
43
  end
@@ -154,7 +156,7 @@ module ActiveType
154
156
  end
155
157
  end
156
158
 
157
- def attribute(name, type)
159
+ def attribute(name, type = nil)
158
160
  self.virtual_columns_hash = virtual_columns_hash.merge(name.to_s => VirtualColumn.new(name, type))
159
161
  AccessorGenerator.new(generated_virtual_attribute_methods).generate_accessors(name)
160
162
  end
@@ -9,6 +9,7 @@ module ObjectSpec
9
9
  attribute :virtual_time, :datetime
10
10
  attribute :virtual_date, :date
11
11
  attribute :virtual_boolean, :boolean
12
+ attribute :virtual_attribute
12
13
 
13
14
  end
14
15
 
@@ -142,6 +143,10 @@ describe ActiveType::Object do
142
143
  describe 'boolean columns' do
143
144
  it_should_behave_like 'a coercible boolean column', :virtual_boolean
144
145
  end
146
+
147
+ describe 'untyped columns' do
148
+ it_should_behave_like 'an untyped column', :virtual_attribute
149
+ end
145
150
  end
146
151
 
147
152
  describe 'inherited classes' do
@@ -9,6 +9,7 @@ module RecordSpec
9
9
  attribute :virtual_time, :datetime
10
10
  attribute :virtual_date, :date
11
11
  attribute :virtual_boolean, :boolean
12
+ attribute :virtual_attribute
12
13
 
13
14
  end
14
15
 
@@ -133,6 +134,10 @@ describe ActiveType::Record do
133
134
  it_should_behave_like 'a coercible boolean column', :persisted_boolean
134
135
  it_should_behave_like 'a coercible boolean column', :virtual_boolean
135
136
  end
137
+
138
+ describe 'untyped columns' do
139
+ it_should_behave_like 'an untyped column', :virtual_attribute
140
+ end
136
141
  end
137
142
 
138
143
  describe 'validations' do
@@ -201,3 +201,28 @@ shared_examples_for 'a coercible boolean column' do |column|
201
201
  end
202
202
 
203
203
  end
204
+
205
+ shared_examples_for 'an untyped column' do |column|
206
+ it 'is nil by default' do
207
+ subject.send(column).should be_nil
208
+ end
209
+
210
+ it 'leaves strings alone' do
211
+ subject.send(:"#{column}=", "string")
212
+
213
+ subject.send(column).should == "string"
214
+ end
215
+
216
+ it 'leaves integers alone' do
217
+ subject.send(:"#{column}=", 17)
218
+
219
+ subject.send(column).should == 17
220
+ end
221
+
222
+ it 'leaves objects alone' do
223
+ object = Object.new
224
+ subject.send(:"#{column}=", object)
225
+
226
+ subject.send(column).should == object
227
+ end
228
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze