elastic_record 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,16 +60,16 @@ module ElasticRecord
60
60
  clone.offset! value
61
61
  end
62
62
 
63
- def select!(value)
64
- self.select_values += Array.wrap(value)
63
+ def select!(*args)
64
+ self.select_values += args.flatten
65
65
  self
66
66
  end
67
67
 
68
- def select(value, &block)
68
+ def select(*args, &block)
69
69
  if block_given?
70
70
  to_a.select(&block)
71
71
  else
72
- clone.select! value
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: