appoxy-simple_record 1.1.12 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,7 +51,7 @@ NOTE: All objects will automatically have :id, :created, :updated attributes.
51
51
 
52
52
  Add string attributes.
53
53
 
54
- class MyModel
54
+ class MyModel < SimpleRecord::Base
55
55
  has_attributes :name
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ Add string attributes.
59
59
 
60
60
  Lets simple_record know that certain attributes defined in has_attributes should be treated as integers, dates or booleans. This is required because SimpleDB only has strings so SimpleRecord needs to know how to convert, pad, offset, etc.
61
61
 
62
- class MyModel
62
+ class MyModel < SimpleRecord::Base
63
63
  has_attributes :name
64
64
  has_ints :age, :height
65
65
  has_dates :birthday
@@ -70,7 +70,7 @@ Lets simple_record know that certain attributes defined in has_attributes should
70
70
 
71
71
  Creates a many-to-one relationship. Can only have one per belongs_to call.
72
72
 
73
- class MyModel
73
+ class MyModel < SimpleRecord::Base
74
74
  belongs_to :school
75
75
  has_attributes :name
76
76
  has_ints :age, :height
@@ -86,7 +86,7 @@ Which requires another class called 'School' or you can specify the class explic
86
86
 
87
87
  If you want to use a custom domain for a model object, you can specify it with set_table_name (or set_domain_name).
88
88
 
89
- class SomeModel
89
+ class SomeModel < SimpleRecord::Base
90
90
  set_table_name :different_model
91
91
  end
92
92
 
@@ -261,7 +261,7 @@ module SimpleRecord
261
261
 
262
262
  def make_dirty(arg, value)
263
263
  # todo: only set dirty if it changed
264
- #puts 'making dirty ' + @dirty.inspect
264
+ #puts 'making dirty arg=' + arg.to_s + ' --- ' + @dirty.inspect
265
265
  @dirty[arg] = get_attribute(arg) # Store old value (not sure if we need it?)
266
266
  #puts 'end making dirty ' + @dirty.inspect
267
267
  end
@@ -271,7 +271,7 @@ module SimpleRecord
271
271
  defined_attributes[arg] = SimpleRecord::Base::Attribute.new(:string) if defined_attributes[arg].nil?
272
272
  # define reader method
273
273
  arg_s = arg.to_s # to get rid of all the to_s calls
274
- send :define_method, arg do
274
+ send(:define_method, arg) do
275
275
  ret = nil
276
276
  ret = get_attribute(arg)
277
277
  return nil if ret.nil?
@@ -279,16 +279,15 @@ module SimpleRecord
279
279
  end
280
280
 
281
281
  # define writer method
282
- method_name = (arg_s+"=")
283
- send(:define_method, method_name) do |value|
282
+ send(:define_method, arg_s+"=") do |value|
284
283
  make_dirty(arg_s, value)
285
- self[arg.to_s]=value
284
+ self[arg_s]=value
286
285
  end
287
286
 
288
287
  # Now for dirty methods: http://api.rubyonrails.org/classes/ActiveRecord/Dirty.html
289
288
  # define changed? method
290
289
  send(:define_method, arg_s + "_changed?") do
291
- !@dirty[arg_s].nil?
290
+ @dirty.has_key?(arg_s)
292
291
  end
293
292
 
294
293
  # define change method
@@ -490,7 +489,7 @@ module SimpleRecord
490
489
  end
491
490
 
492
491
  def []=(attribute, values)
493
- @dirty[attribute] = get_attribute(attribute)
492
+ make_dirty(attribute, values)
494
493
  super
495
494
  end
496
495
 
@@ -178,7 +178,7 @@ class TestSimpleRecord < Test::Unit::TestCase
178
178
 
179
179
  mms = MyModel.find(:all) # select 2
180
180
  assert mms.size > 0 # select 3
181
- assert mms.size == count # skipped
181
+ assert mms.size == count, "size != count! size=" + mms.size.to_s + " count=" + count.to_s
182
182
  assert SimpleRecord.stats.selects == 3, "should have been 3 select, but was actually #{SimpleRecord.stats.selects}" # count should not have been called twice
183
183
 
184
184
  count = MyModel.find(:count, :conditions=>["name=?", "Travis"])
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.12
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-08-18 00:00:00 -07:00
13
+ date: 2009-08-23 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16