cerealize 0.8.4 → 0.8.5
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.
- data/CHANGES +9 -0
- data/cerealize.gemspec +1 -1
- data/lib/cerealize/version.rb +1 -1
- data/lib/cerealize.rb +4 -3
- data/test/test_basic.rb +19 -0
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
= cerealize changes history
|
2
2
|
|
3
|
+
== cerealize 0.8.5 -- 2010-09-29
|
4
|
+
|
5
|
+
* Fix a bug that nil can't be set in cerealized column.
|
6
|
+
This shows the bug:
|
7
|
+
|
8
|
+
apple = Apple.find(Apple.create(:data => [5]).id)
|
9
|
+
apple.update_attributes(:data => nil)
|
10
|
+
assert_equal nil, apple.data # => shouldn't be [5]
|
11
|
+
|
3
12
|
== cerealize 0.8.4 -- 2010-09-29
|
4
13
|
|
5
14
|
* Fixed activerecord dependency, should be <3
|
data/cerealize.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cerealize}
|
5
|
-
s.version = "0.8.
|
5
|
+
s.version = "0.8.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Cardinal Blue", "Lin Jen-Shin (aka godfat 真常)", "Jaime Cham"]
|
data/lib/cerealize/version.rb
CHANGED
data/lib/cerealize.rb
CHANGED
@@ -151,7 +151,7 @@ module Cerealize
|
|
151
151
|
mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
152
152
|
def #{property}_update_if_dirty
|
153
153
|
# See if we have a new cur value
|
154
|
-
if
|
154
|
+
if instance_variable_defined?('@#{property}')
|
155
155
|
value = #{field_cache}
|
156
156
|
value_enc = cerealize_encode(:#{property}, value)
|
157
157
|
|
@@ -164,10 +164,11 @@ module Cerealize
|
|
164
164
|
value != cerealize_decode(:#{property}, #{field_orig}))
|
165
165
|
self[:#{property}] = value_enc
|
166
166
|
end
|
167
|
+
|
168
|
+
remove_instance_variable('@#{property}')
|
167
169
|
end
|
168
170
|
|
169
|
-
self.#{field_orig}
|
170
|
-
self.#{field_cache} = nil
|
171
|
+
self.#{field_orig} = nil
|
171
172
|
end
|
172
173
|
RUBY
|
173
174
|
|
data/test/test_basic.rb
CHANGED
@@ -34,6 +34,25 @@ class BasicTest < Test::Unit::TestCase
|
|
34
34
|
assert_equal 'mood: cheerful', Dog.new(:mood => 'cheerful').mood
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_setting_nil_in_hash
|
38
|
+
apple = Apple.create(:data => {:name => 'pine'})
|
39
|
+
assert_equal({:name => 'pine'}, apple.data)
|
40
|
+
assert_equal 'pine', apple.name
|
41
|
+
apple.data[:name] = nil
|
42
|
+
assert_equal nil, apple.name
|
43
|
+
apple.save; apple.reload
|
44
|
+
assert_equal nil, apple.name
|
45
|
+
assert_equal({:name => nil}, apple.data)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_save_nil
|
49
|
+
apple = Apple.find(Apple.create(:data => [5]).id)
|
50
|
+
assert_equal [5], apple.data
|
51
|
+
apple.update_attributes(:data => nil)
|
52
|
+
assert_equal nil, apple.data
|
53
|
+
assert_equal nil, Apple.find(apple.id).data
|
54
|
+
end
|
55
|
+
|
37
56
|
def test_encoding_yaml
|
38
57
|
set_encoding(:yaml)
|
39
58
|
Boat.create :name => 'yamato', :captain => Person.new('kosaku')
|