appoxy-simple_record 1.1.16 → 1.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_record.rb +9 -1
- data/test/test_simple_record.rb +32 -8
- metadata +4 -4
data/lib/simple_record.rb
CHANGED
@@ -81,6 +81,10 @@ module SimpleRecord
|
|
81
81
|
include SimpleRecord::Callbacks
|
82
82
|
|
83
83
|
|
84
|
+
def initialize(attrs={})
|
85
|
+
super
|
86
|
+
# Need to deal with objects passed in. iterate through belongs_to perhaps and if in attrs, set the objects id rather than the object itself
|
87
|
+
end
|
84
88
|
|
85
89
|
|
86
90
|
# todo: move into Callbacks module
|
@@ -181,7 +185,8 @@ module SimpleRecord
|
|
181
185
|
|
182
186
|
def defined_attributes_local
|
183
187
|
#puts 'local defined_attributes'
|
184
|
-
self.class.defined_attributes
|
188
|
+
ret = self.class.defined_attributes
|
189
|
+
ret.merge!(self.class.superclass.defined_attributes) if self.class.superclass.respond_to?(:defined_attributes)
|
185
190
|
end
|
186
191
|
|
187
192
|
|
@@ -305,6 +310,9 @@ module SimpleRecord
|
|
305
310
|
end
|
306
311
|
end
|
307
312
|
|
313
|
+
def self.has_strings(*args)
|
314
|
+
has_attributes(*args)
|
315
|
+
end
|
308
316
|
def self.has_ints(*args)
|
309
317
|
has_attributes(*args)
|
310
318
|
are_ints(*args)
|
data/test/test_simple_record.rb
CHANGED
@@ -196,6 +196,7 @@ class TestSimpleRecord < Test::Unit::TestCase
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def test_attributes_correct
|
199
|
+
# child should contain child class attributes + parent class attributes
|
199
200
|
|
200
201
|
#MyModel.defined_attributes.each do |a|
|
201
202
|
#
|
@@ -207,13 +208,22 @@ class TestSimpleRecord < Test::Unit::TestCase
|
|
207
208
|
|
208
209
|
# ensures that it uses next token and what not
|
209
210
|
def test_big_result
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
211
|
+
mms = MyModel.find(:all)
|
212
|
+
mms.each do |x|
|
213
|
+
x.delete
|
214
|
+
end
|
215
|
+
num_made = 110
|
216
|
+
num_made.times do |i|
|
217
|
+
mm = MyModel.create(:name=>"Travis", :age=>32, :cool=>true)
|
218
|
+
end
|
219
|
+
rs = MyModel.find(:all) # should get 100 at a time
|
220
|
+
assert rs.size == num_made
|
221
|
+
i = 0
|
222
|
+
rs.each do |x|
|
223
|
+
#puts 'x=' + x.id
|
224
|
+
i+=1
|
225
|
+
end
|
226
|
+
assert i == num_made
|
217
227
|
end
|
218
228
|
|
219
229
|
def test_results_array
|
@@ -223,9 +233,23 @@ class TestSimpleRecord < Test::Unit::TestCase
|
|
223
233
|
assert !mms.empty?
|
224
234
|
assert mms.include?(mms[0])
|
225
235
|
|
226
|
-
assert mms[2,2].size == 2
|
236
|
+
assert mms[2, 2].size == 2
|
227
237
|
assert mms[2..5].size == 4
|
228
238
|
assert mms[2...5].size == 3
|
229
239
|
|
230
240
|
end
|
241
|
+
|
242
|
+
def test_objects_in_constructor
|
243
|
+
mm = MyModel.new(:name=>"model1")
|
244
|
+
mm.save
|
245
|
+
mcm = MyChildModel.new(:name=>"johnny", :my_model=>mm)
|
246
|
+
mcm.save
|
247
|
+
|
248
|
+
assert !mcm.my_model.nil?
|
249
|
+
|
250
|
+
mcm = MyChildModel.find(mcm.id)
|
251
|
+
assert !mcm.my_model.nil?
|
252
|
+
|
253
|
+
|
254
|
+
end
|
231
255
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoxy-simple_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.17
|
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-09-
|
14
|
+
date: 2009-09-21 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -28,7 +28,7 @@ files:
|
|
28
28
|
- lib/simple_record.rb
|
29
29
|
- lib/stats.rb
|
30
30
|
- README.markdown
|
31
|
-
has_rdoc:
|
31
|
+
has_rdoc: true
|
32
32
|
homepage: http://github.com/appoxy/simple_record/
|
33
33
|
licenses:
|
34
34
|
post_install_message:
|
@@ -53,7 +53,7 @@ requirements: []
|
|
53
53
|
rubyforge_project:
|
54
54
|
rubygems_version: 1.3.5
|
55
55
|
signing_key:
|
56
|
-
specification_version:
|
56
|
+
specification_version: 2
|
57
57
|
summary: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
|
58
58
|
test_files:
|
59
59
|
- test/my_child_model.rb
|