gotime-cassandra_object 4.3.1 → 4.3.2
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.
@@ -1,13 +1,17 @@
|
|
1
1
|
module CassandraObject
|
2
2
|
class Scope
|
3
3
|
module QueryMethods
|
4
|
-
def select!(
|
5
|
-
self.select_values +=
|
4
|
+
def select!(*values)
|
5
|
+
self.select_values += values.flatten
|
6
6
|
self
|
7
7
|
end
|
8
8
|
|
9
|
-
def select(
|
10
|
-
|
9
|
+
def select(*values, &block)
|
10
|
+
if block_given?
|
11
|
+
to_a.select(&block)
|
12
|
+
else
|
13
|
+
clone.select! *values
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def where!(*values)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class CassandraObject::QueryMethodsTest < CassandraObject::TestCase
|
3
|
+
class CassandraObject::Scope::QueryMethodsTest < CassandraObject::TestCase
|
4
4
|
test "select" do
|
5
5
|
issue = Issue.create title: 'foo', description: 'bar'
|
6
6
|
|
@@ -9,4 +9,11 @@ class CassandraObject::QueryMethodsTest < CassandraObject::TestCase
|
|
9
9
|
assert_equal 'foo', issue.title
|
10
10
|
assert_nil issue.description
|
11
11
|
end
|
12
|
+
|
13
|
+
test "select with block" do
|
14
|
+
foo_issue = Issue.create title: 'foo'
|
15
|
+
bar_issue = Issue.create title: 'bar'
|
16
|
+
|
17
|
+
assert_equal [foo_issue], Issue.select { |issue| issue.title == 'foo' }
|
18
|
+
end
|
12
19
|
end
|