simple_record 1.4.10 → 1.4.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -240,8 +240,10 @@ module SimpleRecord
240
240
  # end
241
241
  # Client.create_domain #=> {:request_id=>"6fc652a0-0000-41d5-91f4-3ed390a3d3b2", :box_usage=>"0.0055590278"}
242
242
  #
243
- def create_domain
244
- connection.create_domain(domain)
243
+ def create_domain(dom=nil)
244
+ dom = domain if dom.nil?
245
+ puts "Creating new SimpleDB Domain: " + dom
246
+ connection.create_domain(dom)
245
247
  end
246
248
 
247
249
  # Remove domain from SDB.
@@ -251,8 +253,10 @@ module SimpleRecord
251
253
  # end
252
254
  # Client.delete_domain #=> {:request_id=>"e14d90d3-0000-4898-9995-0de28cdda270", :box_usage=>"0.0055590278"}
253
255
  #
254
- def delete_domain
255
- connection.delete_domain(domain)
256
+ def delete_domain(dom=nil)
257
+ dom = domain if dom.nil?
258
+ puts "!!! DELETING SimpleDB Domain: " + dom
259
+ connection.delete_domain(dom)
256
260
  end
257
261
 
258
262
  #
@@ -844,8 +848,9 @@ module SimpleRecord
844
848
  dirty_atts = options[:dirty_atts]
845
849
  atts_to_save.delete_if { |key, value| !dirty_atts.has_key?(key) }
846
850
  end
851
+ dom = options[:domain] || domain
847
852
  #puts 'atts_to_save2=' + atts_to_save.inspect
848
- connection.put_attributes(domain, id, atts_to_save, :replace)
853
+ connection.put_attributes(dom, id, atts_to_save, :replace)
849
854
  apres_save2
850
855
  @attributes
851
856
  end
@@ -948,7 +953,7 @@ module SimpleRecord
948
953
  # @id
949
954
  # end
950
955
 
951
- # Returns true if this object hasn�t been saved yet.
956
+ # Returns true if this object hasn�t been saved yet.
952
957
  def new_record?
953
958
  @new_record
954
959
  end
data/lib/simple_record.rb CHANGED
@@ -338,10 +338,10 @@ module SimpleRecord
338
338
  @@cache_store
339
339
  end
340
340
 
341
- def domain_ok(ex)
341
+ def domain_ok(ex, options={})
342
342
  if (ex.message().index("NoSuchDomain") != nil)
343
- #puts "Creating new SimpleDB Domain: " + domain
344
- self.class.create_domain
343
+ dom = options[:domain] || domain
344
+ self.class.create_domain(dom)
345
345
  return true
346
346
  end
347
347
  return false
@@ -390,6 +390,7 @@ module SimpleRecord
390
390
  # Options:
391
391
  # - :except => Array of attributes to NOT save
392
392
  # - :dirty => true - Will only store attributes that were modified. To make it save regardless and have it update the :updated value, include this and set it to false.
393
+ # - :domain => Explicitly define domain to use.
393
394
  #
394
395
  def save(options={})
395
396
  # puts 'SAVING: ' + self.inspect if SimpleRecord.logging?
@@ -431,9 +432,9 @@ module SimpleRecord
431
432
  else
432
433
  return false
433
434
  end
434
- rescue Aws::AwsError
435
+ rescue Aws::AwsError => ex
435
436
  # puts "RESCUED in save: " + $!
436
- if (domain_ok($!))
437
+ if (domain_ok(ex, options))
437
438
  if !@create_domain_called
438
439
  @create_domain_called = true
439
440
  save(options)
@@ -1,8 +1,8 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
-
3
- class MyBaseModel < SimpleRecord::Base
4
-
5
- has_strings :base_string
6
-
7
-
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
+
3
+ class MyBaseModel < SimpleRecord::Base
4
+
5
+ has_strings :base_string
6
+
7
+
8
8
  end
@@ -1,35 +1,35 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
- require 'my_model'
3
-
4
- class MyChildModel < SimpleRecord::Base
5
- belongs_to :my_model
6
- belongs_to :x, :class_name=>"MyModel"
7
- has_attributes :name, :child_attr
8
-
9
- end
10
-
11
-
12
- =begin
13
-
14
-
15
- puts 'word'
16
-
17
- mm = MyModel.new
18
- puts 'word2'
19
-
20
- mcm = MyChildModel.new
21
-
22
- puts 'mcm instance methods=' + MyChildModel.instance_methods(true).inspect
23
- #puts 'mcm=' + mcm.instance_methods(false)
24
- puts 'mcm class vars = ' + mcm.class.class_variables.inspect
25
- puts mcm.class == MyChildModel
26
- puts 'saved? ' + mm.save.to_s
27
- puts mm.errors.inspect
28
-
29
- puts "mm attributes=" + MyModel.defined_attributes.inspect
30
- puts "mcm attributes=" + MyChildModel.defined_attributes.inspect
31
-
32
- mcm2 = MyChildModel.new
33
- puts "mcm2 attributes=" + MyChildModel.defined_attributes.inspect
34
-
35
- =end
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
+ require 'my_model'
3
+
4
+ class MyChildModel < SimpleRecord::Base
5
+ belongs_to :my_model
6
+ belongs_to :x, :class_name=>"MyModel"
7
+ has_attributes :name, :child_attr
8
+
9
+ end
10
+
11
+
12
+ =begin
13
+
14
+
15
+ puts 'word'
16
+
17
+ mm = MyModel.new
18
+ puts 'word2'
19
+
20
+ mcm = MyChildModel.new
21
+
22
+ puts 'mcm instance methods=' + MyChildModel.instance_methods(true).inspect
23
+ #puts 'mcm=' + mcm.instance_methods(false)
24
+ puts 'mcm class vars = ' + mcm.class.class_variables.inspect
25
+ puts mcm.class == MyChildModel
26
+ puts 'saved? ' + mm.save.to_s
27
+ puts mm.errors.inspect
28
+
29
+ puts "mm attributes=" + MyModel.defined_attributes.inspect
30
+ puts "mcm attributes=" + MyChildModel.defined_attributes.inspect
31
+
32
+ mcm2 = MyChildModel.new
33
+ puts "mcm2 attributes=" + MyChildModel.defined_attributes.inspect
34
+
35
+ =end
@@ -1,15 +1,15 @@
1
-
2
- require File.expand_path(File.dirname(__FILE__) + "/../lib/results_array")
3
-
4
- array = SimpleRecord::ResultsArray.new()
5
- #array.extend(ResultsArray)
6
-
7
- 500.times do |i|
8
- array << "_ob_" + i.to_s
9
- end
10
-
11
- array.each do |v|
12
- puts v.to_s
13
- end
14
-
1
+
2
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/results_array")
3
+
4
+ array = SimpleRecord::ResultsArray.new()
5
+ #array.extend(ResultsArray)
6
+
7
+ 500.times do |i|
8
+ array << "_ob_" + i.to_s
9
+ end
10
+
11
+ array.each do |v|
12
+ puts v.to_s
13
+ end
14
+
15
15
  puts array[10]
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_record
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 4
8
- - 10
9
- version: 1.4.10
9
+ - 11
10
+ version: 1.4.11
10
11
  platform: ruby
11
12
  authors:
12
13
  - Travis Reeder
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-09-01 00:00:00 -07:00
20
+ date: 2010-09-13 00:00:00 -07:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
@@ -27,6 +28,7 @@ dependencies:
27
28
  requirements:
28
29
  - - ">="
29
30
  - !ruby/object:Gem::Version
31
+ hash: 3
30
32
  segments:
31
33
  - 0
32
34
  version: "0"
@@ -55,26 +57,26 @@ files:
55
57
  - lib/simple_record/stats.rb
56
58
  - lib/simple_record/translations.rb
57
59
  - README.markdown
58
- - test/conversions.rb
59
- - test/model_with_enc.rb
60
- - test/my_base_model.rb
61
- - test/my_child_model.rb
62
- - test/my_model.rb
60
+ - test/test_lobs.rb
63
61
  - test/paging_array_test.rb
64
- - test/temp.rb
65
- - test/temp_test.rb
66
- - test/test_base.rb
62
+ - test/test_marshalled.rb
67
63
  - test/test_dirty.rb
68
- - test/test_encodings.rb
69
- - test/test_global_options.rb
70
64
  - test/test_helpers.rb
71
- - test/test_json.rb
72
- - test/test_lobs.rb
73
- - test/test_marshalled.rb
65
+ - test/test_base.rb
74
66
  - test/test_pagination.rb
67
+ - test/my_base_model.rb
68
+ - test/my_child_model.rb
69
+ - test/test_global_options.rb
75
70
  - test/test_results_array.rb
76
- - test/test_simple_record.rb
77
71
  - test/test_usage.rb
72
+ - test/conversions.rb
73
+ - test/temp_test.rb
74
+ - test/test_encodings.rb
75
+ - test/test_json.rb
76
+ - test/test_simple_record.rb
77
+ - test/temp.rb
78
+ - test/model_with_enc.rb
79
+ - test/my_model.rb
78
80
  has_rdoc: true
79
81
  homepage: http://github.com/appoxy/simple_record/
80
82
  licenses: []
@@ -89,6 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
91
  requirements:
90
92
  - - ">="
91
93
  - !ruby/object:Gem::Version
94
+ hash: 3
92
95
  segments:
93
96
  - 0
94
97
  version: "0"
@@ -97,6 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
100
  requirements:
98
101
  - - ">="
99
102
  - !ruby/object:Gem::Version
103
+ hash: 3
100
104
  segments:
101
105
  - 0
102
106
  version: "0"
@@ -108,23 +112,23 @@ signing_key:
108
112
  specification_version: 3
109
113
  summary: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
110
114
  test_files:
111
- - test/conversions.rb
112
- - test/model_with_enc.rb
113
- - test/my_base_model.rb
114
- - test/my_child_model.rb
115
- - test/my_model.rb
115
+ - test/test_lobs.rb
116
116
  - test/paging_array_test.rb
117
- - test/temp.rb
118
- - test/temp_test.rb
119
- - test/test_base.rb
117
+ - test/test_marshalled.rb
120
118
  - test/test_dirty.rb
121
- - test/test_encodings.rb
122
- - test/test_global_options.rb
123
119
  - test/test_helpers.rb
124
- - test/test_json.rb
125
- - test/test_lobs.rb
126
- - test/test_marshalled.rb
120
+ - test/test_base.rb
127
121
  - test/test_pagination.rb
122
+ - test/my_base_model.rb
123
+ - test/my_child_model.rb
124
+ - test/test_global_options.rb
128
125
  - test/test_results_array.rb
129
- - test/test_simple_record.rb
130
126
  - test/test_usage.rb
127
+ - test/conversions.rb
128
+ - test/temp_test.rb
129
+ - test/test_encodings.rb
130
+ - test/test_json.rb
131
+ - test/test_simple_record.rb
132
+ - test/temp.rb
133
+ - test/model_with_enc.rb
134
+ - test/my_model.rb