datastax_rails 1.0.12 → 1.0.13

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.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datastax_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 12
10
- version: 1.0.12
9
+ - 13
10
+ version: 1.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason M. Kusar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-14 00:00:00 Z
18
+ date: 2012-08-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -127,7 +127,6 @@ files:
127
127
  - lib/datastax_rails/cql.rb
128
128
  - lib/datastax_rails/schema.rb
129
129
  - lib/datastax_rails/rsolr_client_wrapper.rb
130
- - lib/datastax_rails/cursor.rb
131
130
  - lib/datastax_rails/associations.rb
132
131
  - lib/datastax_rails/log_subscriber.rb
133
132
  - lib/datastax_rails/mocking.rb
@@ -261,9 +260,7 @@ files:
261
260
  - spec/dummy/app/helpers/application_helper.rb
262
261
  - spec/dummy/app/controllers/application_controller.rb
263
262
  - spec/dummy/app/views/layouts/application.html.erb
264
- - spec/dummy/log/development.log
265
263
  - spec/dummy/log/test.log
266
- - spec/dummy/log/production.log
267
264
  homepage: https://github.com/jasonmk/datastax_rails
268
265
  licenses: []
269
266
 
@@ -349,7 +346,5 @@ test_files:
349
346
  - spec/dummy/app/helpers/application_helper.rb
350
347
  - spec/dummy/app/controllers/application_controller.rb
351
348
  - spec/dummy/app/views/layouts/application.html.erb
352
- - spec/dummy/log/development.log
353
349
  - spec/dummy/log/test.log
354
- - spec/dummy/log/production.log
355
350
  has_rdoc:
@@ -1,90 +0,0 @@
1
- module DatastaxRails
2
- class Cursor
3
- include Consistency
4
-
5
- def initialize(target_class, column_family, key, super_column, options={})
6
- @target_class = target_class
7
- @column_family = column_family
8
- @key = key.to_s
9
- @super_column = super_column
10
- @options = options
11
- @validators = []
12
- end
13
-
14
- def find(number_to_find)
15
- limit = number_to_find
16
- objects = DatastaxRails::Collection.new
17
- out_of_keys = false
18
-
19
- if start_with = @options[:start_after]
20
- limit += 1
21
- else
22
- start_with = nil
23
- end
24
-
25
- while objects.size < number_to_find && !out_of_keys
26
- index_results = connection.get(@column_family, @key, @super_column,
27
- :count => limit,
28
- :start => start_with,
29
- :reversed => @options[:reversed],
30
- :consistency => @target_class.thrift_read_consistency)
31
-
32
- out_of_keys = index_results.size < limit
33
-
34
- if !start_with.blank?
35
- index_results.delete(start_with)
36
- end
37
-
38
- keys = index_results.keys
39
- values = index_results.values
40
-
41
- missing_keys = []
42
-
43
- results = values.empty? ? {} : @target_class.multi_get(values)
44
- results.each do |(key, result)|
45
- if result.nil?
46
- missing_keys << key
47
- end
48
- end
49
-
50
- unless missing_keys.empty?
51
- @target_class.multi_get(missing_keys, :quorum=>true).each do |(key, result)|
52
- index_key = index_results.key(key)
53
- if result.nil?
54
- remove(index_key)
55
- results.delete(key)
56
- else
57
- results[key] = result
58
- end
59
- end
60
- end
61
-
62
- results.values.each do |o|
63
- if @validators.all? {|v| v.call(o) }
64
- objects << o
65
- else
66
- remove(index_results.index(o.key))
67
- end
68
- end
69
-
70
- start_with = objects.last_column_name = keys.last
71
- limit = (number_to_find - results.size) + 1
72
-
73
- end
74
-
75
- return objects
76
- end
77
-
78
- def connection
79
- @target_class.connection
80
- end
81
-
82
- def remove(index_key)
83
- connection.remove(@column_family, @key, @super_column, index_key, :consistency => @target_class.thrift_write_consistency)
84
- end
85
-
86
- def validator(&validator)
87
- @validators << validator
88
- end
89
- end
90
- end