cassilds-model 0.0.6 → 0.0.7
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.
File without changes
|
@@ -113,6 +113,13 @@ module CassandraModel
|
|
113
113
|
def where(search_clauses)
|
114
114
|
find_where(search_clauses)
|
115
115
|
end
|
116
|
+
|
117
|
+
# key
|
118
|
+
# column[s]
|
119
|
+
# options
|
120
|
+
def select(key, columns, options = {})
|
121
|
+
find_select(key, columns, options)
|
122
|
+
end
|
116
123
|
|
117
124
|
private
|
118
125
|
|
@@ -216,6 +223,35 @@ module CassandraModel
|
|
216
223
|
}
|
217
224
|
return records
|
218
225
|
end
|
226
|
+
|
227
|
+
# key
|
228
|
+
# column[s]
|
229
|
+
# options
|
230
|
+
def find_select(key, columns, options)
|
231
|
+
key = validate_key_type(key)
|
232
|
+
raise(RecordNotFound, "Couldn't find #{name} without an ID") if key.blank?
|
233
|
+
raise(CassandraModelError, "Columns param cannot be nil") if columns.nil?
|
234
|
+
options = options || {}
|
235
|
+
readonly = options.delete(:readonly)
|
236
|
+
column_names = []
|
237
|
+
if columns.kind_of?(String)
|
238
|
+
column_names = columns.split(',').collect! {|n| n.strip!}
|
239
|
+
elsif columns.kind_of?(Array)
|
240
|
+
column_names = columns
|
241
|
+
else
|
242
|
+
raise(CassandraModelError, "Invalid columns #{columns}")
|
243
|
+
end
|
244
|
+
|
245
|
+
model = nil
|
246
|
+
benchmark("CassandraModel[#{self.name}].find_select, key: #{key.to_s}, columns: #{column_names.to_s}") do
|
247
|
+
attrs = connection.get_columns(column_family, key, column_names, options)
|
248
|
+
unless attrs.empty?
|
249
|
+
model = init_model(key, attrs)
|
250
|
+
model.readonly! if readonly
|
251
|
+
end
|
252
|
+
end
|
253
|
+
return model
|
254
|
+
end
|
219
255
|
|
220
256
|
def find_every(options)
|
221
257
|
options = options || {}
|
@@ -297,6 +333,7 @@ module CassandraModel
|
|
297
333
|
end
|
298
334
|
|
299
335
|
def validate_key_type(key)
|
336
|
+
raise RecordNotFound, "Couldn't find #{name} without an ID" if key.blank?
|
300
337
|
if !self.key_type.blank? and self.key_type.downcase == 'time_uuid'
|
301
338
|
key = SimpleUUID::UUID.new(key)
|
302
339
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassilds-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
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: 2011-08
|
13
|
+
date: 2011-09-08 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: shoulda
|
17
|
-
requirement: &
|
17
|
+
requirement: &16586640 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *16586640
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: cassilds
|
28
|
-
requirement: &
|
28
|
+
requirement: &16586220 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *16586220
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: simple_uuid
|
39
|
-
requirement: &
|
39
|
+
requirement: &16585660 !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: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *16585660
|
48
48
|
description: Cassandra-model allows you to map ColumnFamily/SuperColumnFamily in Cassandra
|
49
49
|
to Ruby objects. It was designed to be fast and simple.
|
50
50
|
email:
|
@@ -62,7 +62,7 @@ files:
|
|
62
62
|
- LICENSE
|
63
63
|
- README.rdoc
|
64
64
|
- Rakefile
|
65
|
-
-
|
65
|
+
- cassilds-model.gemspec
|
66
66
|
- lib/cassandra-model.rb
|
67
67
|
- lib/cassandra-model/base.rb
|
68
68
|
- lib/cassandra-model/batches.rb
|