gotime-cassandra_object 2.10.8 → 2.10.9
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.
@@ -27,8 +27,8 @@ module CassandraObject
|
|
27
27
|
# attribute :ammo, type: Ammo, coder: AmmoCodec
|
28
28
|
#
|
29
29
|
def attribute(name, options)
|
30
|
-
type = options
|
31
|
-
coder = options
|
30
|
+
type = options[:type]
|
31
|
+
coder = options[:coder]
|
32
32
|
|
33
33
|
if type.is_a?(Symbol)
|
34
34
|
coder = CassandraObject::Type.get_coder(type) || (raise "Unknown type #{type}")
|
@@ -3,8 +3,8 @@ module CassandraObject
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
attribute :created_at, type: :time
|
7
|
-
attribute :updated_at, type: :time
|
6
|
+
attribute :created_at, type: :time
|
7
|
+
attribute :updated_at, type: :time
|
8
8
|
|
9
9
|
before_create do
|
10
10
|
self.created_at ||= Time.current
|
data/test/unit/identity_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotime-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
|
-
requirement: &
|
17
|
+
requirement: &70116309308060 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70116309308060
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: cassandra
|
28
|
-
requirement: &
|
28
|
+
requirement: &70116309307600 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.12.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70116309307600
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &70116309307220 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70116309307220
|
48
48
|
description: Cassandra ActiveModel
|
49
49
|
email: gems@gotime.com
|
50
50
|
executables: []
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- lib/cassandra_object/collection.rb
|
72
72
|
- lib/cassandra_object/connection.rb
|
73
73
|
- lib/cassandra_object/consistency.rb
|
74
|
-
- lib/cassandra_object/cursor.rb
|
75
74
|
- lib/cassandra_object/errors.rb
|
76
75
|
- lib/cassandra_object/finder_methods.rb
|
77
76
|
- lib/cassandra_object/generators/migration_generator.rb
|
@@ -1,90 +0,0 @@
|
|
1
|
-
module CassandraObject
|
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 = CassandraObject::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
|