gotime-cassandra_object 4.7.3 → 4.8.0
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.
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'gotime-cassandra_object'
|
5
|
-
s.version = '4.
|
5
|
+
s.version = '4.8.0'
|
6
6
|
s.description = 'Cassandra ActiveModel'
|
7
7
|
s.summary = 'Cassandra ActiveModel'
|
8
8
|
s.authors = ["Michael Koziarski", "gotime"]
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_runtime_dependency('activemodel', '>= 3.0')
|
21
21
|
s.add_runtime_dependency('cassandra-cql')
|
22
|
-
s.add_runtime_dependency('thrift_client', '~> 0.
|
22
|
+
s.add_runtime_dependency('thrift_client', '~> 0.9.0')
|
23
23
|
|
24
24
|
s.add_development_dependency('bundler')
|
25
25
|
end
|
@@ -2,6 +2,10 @@ module CassandraObject
|
|
2
2
|
module Persistence
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
+
included do
|
6
|
+
class_attribute :batch_statements
|
7
|
+
end
|
8
|
+
|
5
9
|
module ClassMethods
|
6
10
|
def remove(id)
|
7
11
|
execute_batchable_cql "DELETE FROM #{column_family}#{write_option_string} WHERE KEY = ?", id
|
@@ -30,15 +34,15 @@ module CassandraObject
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def batching?
|
33
|
-
|
37
|
+
!batch_statements.nil?
|
34
38
|
end
|
35
39
|
|
36
40
|
def batch
|
37
|
-
|
41
|
+
self.batch_statements = []
|
38
42
|
yield
|
39
|
-
execute_cql(batch_statement) if
|
43
|
+
execute_cql(batch_statement) if batch_statements.any?
|
40
44
|
ensure
|
41
|
-
|
45
|
+
self.batch_statements = nil
|
42
46
|
end
|
43
47
|
|
44
48
|
def instantiate(id, attributes)
|
@@ -67,18 +71,18 @@ module CassandraObject
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def batch_statement
|
70
|
-
return nil unless
|
74
|
+
return nil unless batch_statements.any?
|
71
75
|
|
72
76
|
[
|
73
77
|
"BEGIN BATCH#{write_option_string(true)}",
|
74
|
-
|
78
|
+
batch_statements * "\n",
|
75
79
|
'APPLY BATCH'
|
76
80
|
] * "\n"
|
77
81
|
end
|
78
82
|
|
79
83
|
def execute_batchable_cql(cql_string, *bind_vars)
|
80
|
-
if
|
81
|
-
|
84
|
+
if batch_statements
|
85
|
+
batch_statements << CassandraCQL::Statement.sanitize(cql_string, bind_vars)
|
82
86
|
else
|
83
87
|
execute_cql cql_string, *bind_vars
|
84
88
|
end
|
@@ -32,15 +32,17 @@ module CassandraObject
|
|
32
32
|
clone.limit! value
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
def to_cql
|
36
|
+
[
|
37
|
+
"SELECT #{select_string} FROM #{klass.column_family}",
|
38
|
+
consistency_string,
|
39
|
+
where_string,
|
40
|
+
limit_string
|
41
41
|
].delete_if(&:blank?) * ' '
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
+
def to_a
|
45
|
+
instantiate_from_cql(to_cql)
|
44
46
|
end
|
45
47
|
|
46
48
|
private
|
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: 4.
|
4
|
+
version: 4.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -51,14 +51,14 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.9.0
|
55
55
|
none: false
|
56
56
|
type: :runtime
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.9.0
|
62
62
|
none: false
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: bundler
|