simple_record 2.0.2 → 2.0.4

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/README.markdown CHANGED
@@ -167,6 +167,30 @@ For rails, be sure to add this to your Application controller if using per_threa
167
167
  SimpleRecord.close_connection
168
168
  end
169
169
 
170
+ ### LOB and any other S3 Storage
171
+
172
+ :s3_bucket=>...
173
+
174
+ * :old (default) will use the existing lob location of "#{aws_access_key}_lobs", but any new features will use the :new bucket.
175
+ * :new will use the new and recommended s3 bucket location of "simple_record_#{aws_access_key}".
176
+ * Any string value will use that value as the bucket name.
177
+
178
+
179
+ NOTE: All projects should set this as we may make this default in a future major version (v3?). Existing projects should use
180
+ :s3_bucket=>:
181
+
182
+ ### Created and Updated At Columns
183
+
184
+ The default uses the columns "created" and "updated" which unfortunately are not the same as ActiveRecord, which
185
+ uses created_at and updated_at. Although you can use created_at and updated_at methods, you may still want the columns in
186
+ SimpleDB to be created_at and updated_at.
187
+
188
+ :created_col=>"created", :updated_col=>"updated"
189
+
190
+ NOTE: All projects should set these as we may make the "_at" postfix default in a future major version (v3?). Existing
191
+ projects should set :created_col=>"created", :updated_col=>"updated" (default) so if it changes in a future version,
192
+ there won't be any issues.
193
+
170
194
  ## SimpleRecord on Rails
171
195
 
172
196
  You don't really have to do anything except have your models extends SimpleRecord::Base instead of ActiveRecord::Base, but here are some tips you can use.
@@ -200,7 +224,7 @@ string value. There is no support for blobs yet.
200
224
  has_clobs :my_clob
201
225
 
202
226
  These clob values will be stored in s3 under a bucket named "#{aws_access_key}_lobs"
203
- OR "simple_record_#{aws_access_key}/lobs" if you set :new_bucket=>true in establish_connection (RECOMMENDED).
227
+ OR "simple_record_#{aws_access_key}/lobs" if you set :s3_bucket=>:new in establish_connection (RECOMMENDED).
204
228
 
205
229
  If you have more than one clob on an object and if it makes sense for performance reasons, you can set a configuration option on the class to store all clobs
206
230
  as one item on s3 which means it will do a single put to s3 and a single get for all the clobs on the object.
@@ -209,7 +233,7 @@ all the clobs on the object.
209
233
 
210
234
  sr_config :single_clob=>true
211
235
 
212
- Setting this will automatically use :new_bucket=>true as well.
236
+ Setting this will automatically use :s3_bucket=>:new as well.
213
237
 
214
238
  ## Tips and Tricks and Things to Know
215
239
 
@@ -51,6 +51,8 @@ module SimpleRecord
51
51
  # then attribute may have extra options
52
52
  arg_options = arg
53
53
  arg = arg_options[:name].to_sym
54
+ else
55
+ arg = arg.to_sym
54
56
  end
55
57
  type = options_for_all[:type] || :string
56
58
  attr = Attribute.new(type, arg_options)
@@ -119,26 +121,26 @@ module SimpleRecord
119
121
  def are_ints(*args)
120
122
  # puts 'calling are_ints: ' + args.inspect
121
123
  args.each do |arg|
122
- defined_attributes[arg].type = :int
124
+ defined_attributes[arg.to_sym].type = :int
123
125
  end
124
126
  end
125
127
 
126
128
  def are_floats(*args)
127
129
  # puts 'calling are_ints: ' + args.inspect
128
130
  args.each do |arg|
129
- defined_attributes[arg].type = :float
131
+ defined_attributes[arg.to_sym].type = :float
130
132
  end
131
133
  end
132
134
 
133
135
  def are_dates(*args)
134
136
  args.each do |arg|
135
- defined_attributes[arg].type = :date
137
+ defined_attributes[arg.to_sym].type = :date
136
138
  end
137
139
  end
138
140
 
139
141
  def are_booleans(*args)
140
142
  args.each do |arg|
141
- defined_attributes[arg].type = :boolean
143
+ defined_attributes[arg.to_sym].type = :boolean
142
144
  end
143
145
  end
144
146
 
@@ -342,7 +344,7 @@ module SimpleRecord
342
344
  unless new_record?
343
345
  if self.class.get_sr_config[:single_clob]
344
346
  begin
345
- single_clob = s3_bucket(false, :new_bucket=>true).get(single_clob_id)
347
+ single_clob = s3_bucket(false, :s3_bucket=>:new).get(single_clob_id)
346
348
  single_clob = JSON.parse(single_clob)
347
349
  puts "single_clob=" + single_clob.inspect
348
350
  single_clob.each_pair do |name2,val|