simple_record 1.5.3 → 1.5.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/lib/simple_record.rb CHANGED
@@ -158,13 +158,6 @@ module SimpleRecord
158
158
 
159
159
  class Base < SimpleRecord::ActiveSdb::Base
160
160
 
161
- include SimpleRecord::Translations
162
- # include SimpleRecord::Attributes
163
- extend SimpleRecord::Attributes
164
- include SimpleRecord::Callbacks
165
- include SimpleRecord::Json
166
- include SimpleRecord::Logging
167
- extend SimpleRecord::Logging::ClassMethods
168
161
 
169
162
  # puts 'Is ActiveModel defined? ' + defined?(ActiveModel).inspect
170
163
  if defined?(ActiveModel)
@@ -176,6 +169,13 @@ module SimpleRecord
176
169
  include SimpleRecord::Rails2
177
170
  end
178
171
 
172
+ include SimpleRecord::Translations
173
+ # include SimpleRecord::Attributes
174
+ extend SimpleRecord::Attributes
175
+ include SimpleRecord::Callbacks
176
+ include SimpleRecord::Json
177
+ include SimpleRecord::Logging
178
+ extend SimpleRecord::Logging::ClassMethods
179
179
 
180
180
  def self.extended(base)
181
181
 
@@ -230,7 +230,7 @@ module SimpleRecord
230
230
  def persisted?
231
231
  true
232
232
  end
233
-
233
+
234
234
 
235
235
 
236
236
  def defined_attributes_local
@@ -551,7 +551,7 @@ module SimpleRecord
551
551
  def validate
552
552
  true
553
553
  end
554
-
554
+
555
555
  def validate_on_create
556
556
  true
557
557
  end
@@ -1138,7 +1138,7 @@ module SimpleRecord
1138
1138
 
1139
1139
  # This is simply a place holder so we don't keep doing gets to s3 or simpledb if already checked.
1140
1140
  class RemoteNil
1141
-
1141
+
1142
1142
  end
1143
1143
 
1144
1144
 
@@ -61,9 +61,10 @@ module SimpleRecord
61
61
  end
62
62
  # puts 'result[name]=' + result[name].inspect
63
63
  end
64
- ret = result.as_json(options)
64
+ # ret = result.as_json(options)
65
65
  # puts 'ret=' + ret.inspect
66
- return ret
66
+ # return ret
67
+ result
67
68
  end
68
69
 
69
70
  end
@@ -9,20 +9,20 @@ module SimpleRecord
9
9
 
10
10
 
11
11
  def initialize(clz=nil, params=[], results=nil, next_token=nil)
12
- @clz = clz
12
+ @clz = clz
13
13
  #puts 'class=' + clz.inspect
14
14
  @params = params
15
15
  if @params.size <= 1
16
- options = {}
16
+ options = {}
17
17
  @params[1] = options
18
18
  end
19
- @items = results[:items]
19
+ @items = results[:items]
20
20
  @currentset_items = results[:items]
21
- @next_token = next_token
21
+ @next_token = next_token
22
22
  # puts 'bu=' + results[:box_usage]
23
- @box_usage = results[:box_usage].to_f
24
- @request_id = results[:request_id]
25
- @options = @params[1]
23
+ @box_usage = results[:box_usage].to_f
24
+ @request_id = results[:request_id]
25
+ @options = @params[1]
26
26
  if @options[:page]
27
27
  load_to(@options[:per_page] * @options[:page])
28
28
  @start_at = @options[:per_page] * (@options[:page] - 1)
@@ -91,14 +91,14 @@ module SimpleRecord
91
91
  end
92
92
  return @count if @count
93
93
  # puts '@params=' + @params.inspect
94
- params_for_count = @params.dup
94
+ params_for_count = @params.dup
95
95
  params_for_count[0] = :count
96
96
  params_for_count[1] = params_for_count[1].dup # for deep clone
97
97
  params_for_count[1].delete(:limit)
98
- params_for_count[1].delete(:per_token)
98
+ params_for_count[1].delete(:per_token)
99
99
 
100
- # puts '@params2=' + @params.inspect
101
- # puts 'params_for_count=' + params_for_count.inspect
100
+ # puts '@params2=' + @params.inspect
101
+ # puts 'params_for_count=' + params_for_count.inspect
102
102
  @count = clz.find(*params_for_count)
103
103
  # puts '@count=' + @count.to_s
104
104
  @count
@@ -115,8 +115,8 @@ module SimpleRecord
115
115
  def each2(i, &blk)
116
116
  options = @params[1]
117
117
  # puts 'options=' + options.inspect
118
- limit = options[:limit]
119
- # puts 'limit=' + limit.inspect
118
+ limit = options[:limit]
119
+ # puts 'limit=' + limit.inspect
120
120
 
121
121
  if i > @items.size
122
122
  i = @items.size
@@ -192,10 +192,10 @@ module SimpleRecord
192
192
  end
193
193
 
194
194
  def load_next_token_set
195
- options = @params[1]
195
+ options = @params[1]
196
196
  options[:next_token] = @next_token
197
- res = @clz.find(*@params)
198
- @currentset_items = res.items # get the real items array from the ResultsArray
197
+ res = @clz.find(*@params)
198
+ @currentset_items = res.items # get the real items array from the ResultsArray
199
199
  @currentset_items.each do |item|
200
200
  @items << item
201
201
  end
@@ -210,5 +210,18 @@ module SimpleRecord
210
210
  @items.delete_at(index)
211
211
  end
212
212
 
213
+
214
+ # A couple json serialization methods copied from active_support
215
+ def as_json(options = nil) #:nodoc:
216
+ # use encoder as a proxy to call as_json on all elements, to protect from circular references
217
+ encoder = options && options[:encoder] || ActiveSupport::JSON::Encoding::Encoder.new(options)
218
+ map { |v| encoder.as_json(v) }
219
+ end
220
+
221
+ def encode_json(encoder) #:nodoc:
222
+ # we assume here that the encoder has already run as_json on self and the elements, so we run encode_json directly
223
+ "[#{map { |v| v.encode_json(encoder) } * ','}]"
224
+ end
225
+
213
226
  end
214
227
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 3
9
- version: 1.5.3
8
+ - 4
9
+ version: 1.5.4
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-11-13 00:00:00 -08:00
19
+ date: 2010-11-25 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -82,8 +82,8 @@ homepage: http://github.com/appoxy/simple_record/
82
82
  licenses: []
83
83
 
84
84
  post_install_message:
85
- rdoc_options:
86
- - --charset=UTF-8
85
+ rdoc_options: []
86
+
87
87
  require_paths:
88
88
  - lib
89
89
  required_ruby_version: !ruby/object:Gem::Requirement