elastic_record 0.2.2 → 0.2.3
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.
@@ -60,16 +60,16 @@ module ElasticRecord
|
|
60
60
|
clone.offset! value
|
61
61
|
end
|
62
62
|
|
63
|
-
def select!(
|
64
|
-
self.select_values +=
|
63
|
+
def select!(*args)
|
64
|
+
self.select_values += args.flatten
|
65
65
|
self
|
66
66
|
end
|
67
67
|
|
68
|
-
def select(
|
68
|
+
def select(*args, &block)
|
69
69
|
if block_given?
|
70
70
|
to_a.select(&block)
|
71
71
|
else
|
72
|
-
clone.select!
|
72
|
+
clone.select! *args
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -158,6 +158,16 @@ class ElasticRecord::Relation::SearchMethodsTest < MiniTest::Spec
|
|
158
158
|
assert_equal ['foo'], selectable_klass.instance_variable_get('@latest_select')
|
159
159
|
end
|
160
160
|
|
161
|
+
def test_select_with_block
|
162
|
+
Widget.elastic_connection.index({'widget' => {'color' => 'red'}}, {index: 'widgets', type: 'widget', id: 5})
|
163
|
+
Widget.elastic_connection.index({'widget' => {'color' => 'blue'}}, {index: 'widgets', type: 'widget', id: 10})
|
164
|
+
|
165
|
+
records = relation.select { |record| record.id == '5' }
|
166
|
+
|
167
|
+
assert_equal 1, records.size
|
168
|
+
assert_equal '5', records.first.id
|
169
|
+
end
|
170
|
+
|
161
171
|
def test_extending_with_block
|
162
172
|
relation.extending! do
|
163
173
|
def foo
|