appoxy-simple_record 1.0.18 → 1.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/simple_record.rb +41 -8
  2. metadata +2 -2
data/lib/simple_record.rb CHANGED
@@ -28,7 +28,26 @@ require 'sdb/active_sdb'
28
28
 
29
29
  module SimpleRecord
30
30
 
31
- VERSION = '1.0.16'
31
+
32
+ # Create a new handle to an Sdb account. All handles share the same per process or per thread
33
+ # HTTP connection to Amazon Sdb. Each handle is for a specific account.
34
+ # The +params+ are passed through as-is to RightAws::SdbInterface.new
35
+ # Params:
36
+ # { :server => 'sdb.amazonaws.com' # Amazon service host: 'sdb.amazonaws.com'(default)
37
+ # :port => 443 # Amazon service port: 80(default) or 443
38
+ # :protocol => 'https' # Amazon service protocol: 'http'(default) or 'https'
39
+ # :signature_version => '0' # The signature version : '0' or '1'(default)
40
+ # :connection_mode => :default # options are
41
+ # :default (will use best known safe (as in won't need explicit close) option, may change in the future)
42
+ # :per_request (opens and closes a connection on every request to SDB)
43
+ # :single (one thread across entire app)
44
+ # :per_thread (one connection per thread)
45
+ # :pool (uses a connection pool with a maximum number of connections - NOT IMPLEMENTED YET)
46
+ # :logger => Logger Object # Logger instance: logs to STDOUT if omitted
47
+ # :nil_representation => 'mynil'} # interpret Ruby nil as this string value; i.e. use this string in SDB to represent Ruby nils (default is the string 'nil')
48
+ def self.establish_connection(aws_access_key=nil, aws_secret_key=nil, params={})
49
+ RightAws::ActiveSdb.establish_connection(aws_access_key, aws_secret_key, params)
50
+ end
32
51
 
33
52
  class Base < RightAws::ActiveSdb::Base
34
53
 
@@ -134,6 +153,19 @@ module SimpleRecord
134
153
  end
135
154
  end
136
155
 
156
+ def self.has_ints(*args)
157
+ has_attributes(args)
158
+ are_ints(args)
159
+ end
160
+ def self.has_dates(*args)
161
+ has_attributes(args)
162
+ are_dates(args)
163
+ end
164
+ def self.has_booleans(*args)
165
+ has_attributes(args)
166
+ are_booleans(args)
167
+ end
168
+
137
169
  @@ints = []
138
170
  def self.are_ints(*args)
139
171
  # puts 'calling are_ints: ' + args.inspect
@@ -243,7 +275,7 @@ module SimpleRecord
243
275
  end
244
276
  end
245
277
 
246
-
278
+
247
279
  # Define writer method for setting the _id directly without the associated object
248
280
  send(:define_method, arg_id + "=") do |value|
249
281
  if value.nil?
@@ -325,7 +357,7 @@ module SimpleRecord
325
357
 
326
358
  def self.pad_and_offset(x)
327
359
  # todo: add Float, etc
328
- # puts 'padding=' + x.class.name + " -- " + x.inspect
360
+ # puts 'padding=' + x.class.name + " -- " + x.inspect
329
361
  if x.kind_of? Integer
330
362
  x += @@offset
331
363
  x_str = x.to_s
@@ -333,7 +365,7 @@ module SimpleRecord
333
365
  x_str = '0' + x_str while x_str.size < 20
334
366
  return x_str
335
367
  elsif x.respond_to?(:iso8601)
336
- # puts x.class.name + ' responds to iso8601'
368
+ # puts x.class.name + ' responds to iso8601'
337
369
  #
338
370
  # There is an issue here where Time.iso8601 on an incomparable value to DateTime.iso8601.
339
371
  # Amazon suggests: 2008-02-10T16:52:01.000-05:00
@@ -344,7 +376,7 @@ module SimpleRecord
344
376
  else
345
377
  x_str = x.getutc.strftime(@@date_format)
346
378
  end
347
- # puts 'utc=' + x_str
379
+ # puts 'utc=' + x_str
348
380
  return x_str
349
381
  else
350
382
  return x
@@ -420,7 +452,8 @@ module SimpleRecord
420
452
  end
421
453
  end
422
454
  end
423
- def convert_dates_to_sdb()
455
+
456
+ def convert_dates_to_sdb()
424
457
  if !@@dates.nil?
425
458
  for i in @@dates
426
459
  # puts 'int encoding: ' + i.to_s
@@ -710,7 +743,7 @@ This is done on getters now
710
743
  options = params[1]
711
744
  # puts 'options=' + options.inspect
712
745
  convert_condition_params(options)
713
- # puts 'after collect=' + options.inspect
746
+ # puts 'after collect=' + options.inspect
714
747
 
715
748
  results = all ? [] : nil
716
749
  begin
@@ -781,7 +814,7 @@ This is done on getters now
781
814
  class_name = results.class.name
782
815
  id = results.id
783
816
  cache_key = self.cache_key(class_name, id)
784
- puts 'caching result at ' + cache_key + ': ' + results.inspect
817
+ puts 'caching result at ' + cache_key + ': ' + results.inspect
785
818
  @@cache_store.write(cache_key, results, :expires_in =>30)
786
819
  end
787
820
  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.0.18
4
+ version: 1.0.19
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-06-25 00:00:00 -07:00
13
+ date: 2009-06-28 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16