nazrin 2.6.2 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f65c87ab62673a083a1ff25f8bb1ef6895bc711
4
- data.tar.gz: 2720dc6ef684787ddda67c54a2cb9629513bf8fd
3
+ metadata.gz: 8e9cf38a42182748cb66ae4cbe9b0fdee0ee0e28
4
+ data.tar.gz: 1697512262d0dc064e714f916475ca2a98bdfa28
5
5
  SHA512:
6
- metadata.gz: 131440d1483c5239c9097eab18c1ab50d1842fad9463f248748f9fd682f9fdb3ba393be94665e1cdc5dfeb42531e41ed3ddeeccc858cd143518bed2e02995d36
7
- data.tar.gz: 87daa6ba9f73f46c3287fd4853e5e6e280155991a0b68e19e12b9b59216dc7cfa3cbcd9842ce5497239388eb7b75472cdd6ea84049c7be0f1edc116ca203060f
6
+ metadata.gz: aadbe716cbbb97d6a22147a1b0341df7a7ce06b8eef371d3e1e00f2570c1fe1a1d8a2bcb4b809a5a199c98a1d8596ac11241b1c1beb1613901a948d2a4d8c840
7
+ data.tar.gz: 469c6dec4d4fa66a1972a9c4cb5b1d860ad9fd939024ad7e9cb6842652f084e77084cfce4bd4599ece4e4f56f9a526058fb819e9e45ca1b8beab7f8d598f47f5
@@ -4,15 +4,16 @@ module Nazrin
4
4
  # load from activerecord
5
5
  def load_all(ids)
6
6
  records_table = {}
7
- options.each do |k, v|
8
- @model = model.send(k, v)
7
+
8
+ relation = options.reduce(model) do |rel, (k, v)|
9
+ rel.send(k, v)
9
10
  end
10
- model.where(id: ids).each do |record|
11
- records_table[record.id] = record
11
+
12
+ relation.where(id: ids).each do |record|
13
+ records_table[record.id.to_s] = record
12
14
  end
13
- ids.map do |id|
14
- records_table.select { |k, _| k == id.to_i }[id.to_i]
15
- end.reject(&:nil?)
15
+
16
+ records_table.values_at(*ids.map(&:to_s)).compact
16
17
  end
17
18
 
18
19
  def data_from_response(res)
@@ -3,19 +3,16 @@ module Nazrin
3
3
  class Mongoid < Nazrin::DataAccessor
4
4
  def load_all(ids)
5
5
  documents_table = {}
6
- options.each do |k, v|
7
- @model = if v.nil?
8
- model.send(k)
9
- else
10
- model.send(k, v)
11
- end
6
+
7
+ relation = options.reduce(model) do |rel, send_args|
8
+ rel.send(*send_args.compact)
12
9
  end
13
- model.where('_id' => { '$in' => ids }).each do |document|
10
+
11
+ relation.where('_id' => { '$in' => ids }).each do |document|
14
12
  documents_table[document._id.to_s] = document
15
13
  end
16
- ids.map do |id|
17
- documents_table[id]
18
- end.reject(&:nil?)
14
+
15
+ documents_table.values_at(*ids.map(&:to_s)).compact
19
16
  end
20
17
 
21
18
  def data_from_response(res)
@@ -45,6 +45,7 @@ module Nazrin
45
45
 
46
46
  def cloudsearch_client
47
47
  @cloudsearch_client ||= Aws::CloudSearch::Client.new(
48
+ region: config.region,
48
49
  access_key_id: config.access_key_id,
49
50
  secret_access_key: config.secret_access_key,
50
51
  logger: config.logger
@@ -1,3 +1,3 @@
1
1
  module Nazrin
2
- VERSION = '2.6.2'
2
+ VERSION = '2.6.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nazrin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomohiro Suwa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-22 00:00:00.000000000 Z
11
+ date: 2019-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core