simple_record 1.1.28 → 1.1.29
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_record.rb +12 -4
- data/test/test_simple_record.rb +8 -1
- metadata +2 -2
data/lib/simple_record.rb
CHANGED
@@ -600,17 +600,25 @@ module SimpleRecord
|
|
600
600
|
def save(options={})
|
601
601
|
# puts 'SAVING: ' + self.inspect
|
602
602
|
clear_errors
|
603
|
+
# todo: decide whether this should go before pre_save or after pre_save? pre_save dirties "updated" and perhaps other items due to callbacks
|
604
|
+
if options[:dirty] # Only used in simple_record right now
|
605
|
+
puts '@dirty=' + @dirty.inspect
|
606
|
+
return true if @dirty.size == 0 # Nothing to save so skip it
|
607
|
+
options[:dirty_atts] = @dirty
|
608
|
+
end
|
603
609
|
is_create = self[:id].nil?
|
604
610
|
ok = pre_save(options)
|
605
611
|
if ok
|
606
612
|
begin
|
607
613
|
# puts 'is frozen? ' + self.frozen?.to_s + ' - ' + self.inspect
|
608
|
-
if options[:dirty] # Only used in simple_record right now
|
609
|
-
|
610
|
-
|
611
|
-
|
614
|
+
# if options[:dirty] # Only used in simple_record right now
|
615
|
+
# puts '@dirty=' + @dirty.inspect
|
616
|
+
# return true if @dirty.size == 0 # Nothing to save so skip it
|
617
|
+
# options[:dirty_atts] = @dirty
|
618
|
+
# end
|
612
619
|
to_delete = get_atts_to_delete # todo: this should use the @dirty hash now
|
613
620
|
# puts 'done to_delete ' + to_delete.inspect
|
621
|
+
SimpleRecord.stats.puts += 1
|
614
622
|
if super(options)
|
615
623
|
# puts 'SAVED super'
|
616
624
|
self.class.cache_results(self)
|
data/test/test_simple_record.rb
CHANGED
@@ -148,8 +148,15 @@ class TestSimpleRecord < Test::Unit::TestCase
|
|
148
148
|
mm2.name = "Travis 2"
|
149
149
|
mm2.save(:dirty=>true)
|
150
150
|
|
151
|
-
# todo: how do we assert this? perhaps change a value directly in sdb and see that it doesn't get overwritten
|
151
|
+
# todo: how do we assert this? perhaps change a value directly in sdb and see that it doesn't get overwritten.
|
152
|
+
# or check stats and ensure only 1 attribute was put
|
152
153
|
|
154
|
+
# Test to ensure that if an item is not dirty, sdb doesn't get hit
|
155
|
+
puts SimpleRecord.stats.puts.to_s
|
156
|
+
SimpleRecord.stats.clear
|
157
|
+
mm2.save(:dirty=>true)
|
158
|
+
puts SimpleRecord.stats.puts.to_s
|
159
|
+
assert SimpleRecord.stats.puts == 0
|
153
160
|
end
|
154
161
|
|
155
162
|
# http://api.rubyonrails.org/classes/ActiveRecord/Dirty.html#M002136
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-11-
|
14
|
+
date: 2009-11-06 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|