simple_record 1.1.70 → 1.1.71

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/lib/simple_record.rb CHANGED
@@ -63,7 +63,7 @@ module SimpleRecord
63
63
  # :logger => Logger Object # Logger instance: logs to STDOUT if omitted
64
64
  def self.establish_connection(aws_access_key=nil, aws_secret_key=nil, params={})
65
65
  @@options.merge!(params)
66
- puts 'SimpleRecord.establish_connection with ' + @@options.inspect
66
+ puts 'SimpleRecord.establish_connection with options: ' + @@options.inspect
67
67
  Aws::ActiveSdb.establish_connection(aws_access_key, aws_secret_key, @@options)
68
68
  end
69
69
 
@@ -570,7 +570,8 @@ module SimpleRecord
570
570
  attvalue = value.nil? ? nil : value.id
571
571
  else
572
572
  attname = name.to_s
573
- attvalue = value
573
+ attvalue = att_meta.init_value(value)
574
+ #puts 'converted ' + value.inspect + ' to ' + attvalue.inspect
574
575
  end
575
576
  end
576
577
  attvalue = strip_array(attvalue)
@@ -148,7 +148,7 @@ module SimpleRecord
148
148
 
149
149
  # Define ID reader method for reading the associated objects id without getting the entire object
150
150
  send(:define_method, arg_id) do
151
- get_attribute_sdb(arg_s)
151
+ get_attribute_sdb(arg_s)
152
152
  end
153
153
 
154
154
  # Define writer method for setting the _id directly without the associated object
@@ -211,6 +211,16 @@ module SimpleRecord
211
211
  @options = options
212
212
  end
213
213
 
214
+ def init_value(value)
215
+ return value if value.nil?
216
+ ret = value
217
+ case self.type
218
+ when :int
219
+ ret = value.to_i
220
+ end
221
+ ret
222
+ end
223
+
214
224
  end
215
225
 
216
226
  end
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
3
+ require "yaml"
4
+ require 'aws'
5
+ require 'my_model'
6
+ require 'my_child_model'
7
+ require 'active_support'
8
+ require 'test_base'
9
+
10
+
11
+ class Person < SimpleRecord::Base
12
+ has_strings :name, :i_as_s
13
+ has_ints :age
14
+ end
15
+ class TestEncodings < TestBase
16
+
17
+
18
+ end
@@ -55,7 +55,6 @@ class TestSimpleRecord < TestBase
55
55
  end
56
56
 
57
57
 
58
-
59
58
  def test_updates
60
59
  mm = MyModel.new
61
60
  mm.name = "Travis"
@@ -422,7 +421,7 @@ class TestSimpleRecord < TestBase
422
421
  sleep 1
423
422
 
424
423
  # Should be NIL
425
- assert mm.age == nil
424
+ assert mm.age == nil, "age is #{mm.age}"
426
425
 
427
426
  # Should have NO age attributes
428
427
  assert @@sdb.get_attributes('simplerecord_tests_my_models', mm.id, 'age')[:attributes].size == 0
@@ -588,17 +587,24 @@ class TestSimpleRecord < TestBase
588
587
  assert mm.name == "name2", "Name is #{mm.name}"
589
588
  assert mm.age == 21
590
589
  assert mm.date2 == now
590
+ sleep 1
591
+
592
+ mm = MyModel.find(mm.id)
593
+ assert mm.name == "name2", "Name is #{mm.name}"
594
+ assert mm.age == 21, "Age is not 21, it is #{mm.age}"
595
+ assert mm.date2 == now, "Date is not correct, it is #{mm.date2}"
591
596
  end
592
597
 
593
598
  def test_explicit_class_name
594
599
  mm = MyModel.new({:name=>"myname"})
595
600
  mm.save
596
- sleep 1
601
+ sleep 1
597
602
 
598
603
  mm2 = MyChildModel.new({"name"=>"myname2"})
599
604
  mm2.x = mm
600
605
  assert mm2.x.id == mm.id
601
606
  mm2.save
607
+ sleep 1
602
608
 
603
609
  mm3 = MyChildModel.find(mm2.id)
604
610
  puts "mm3.x=" + mm3.x.inspect
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 70
9
- version: 1.1.70
8
+ - 71
9
+ version: 1.1.71
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-03-11 00:00:00 -08:00
19
+ date: 2010-03-22 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -90,6 +90,7 @@ test_files:
90
90
  - test/temp_test.rb
91
91
  - test/test_base.rb
92
92
  - test/test_dirty.rb
93
+ - test/test_encodings.rb
93
94
  - test/test_global_options.rb
94
95
  - test/test_helpers.rb
95
96
  - test/test_results_array.rb