Sha256: 9f5982346bf891de34c6218d05bb721d2922025d2e45e6264a781c6852aebb28

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

module Nazrin
  class DataAccessor
    class Mongoid < Nazrin::DataAccessor
      def load_all(ids)
        documents_table = {}
        options.each do |k, v|
          model = if v.nil?
                     model.send(k)
                   else
                     model.send(k, v)
                   end
        end
        model.where('_id' => { '$in' => ids }).each do |document|
          documents_table[document._id.to_s] = document
        end
        ids.map do |id|
          documents_table[id]
        end.reject(&:nil?)
      end

      def data_from_response(res)
        res.data.hits.hit.map(&:id)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nazrin-2.6.1 lib/nazrin/data_accessor/mongoid.rb
nazrin-2.6.0 lib/nazrin/data_accessor/mongoid.rb
nazrin-2.5.0 lib/nazrin/data_accessor/mongoid.rb