Sha256: 5454ad157604fc5ab152e7a038b2ce14999d6c642904aff04b6c1bcdce7c000f
Contents?: true
Size: 1.43 KB
Versions: 5
Compression:
Stored size: 1.43 KB
Contents
module Gummi module DbLayer module Document module Search module Searching extend ActiveSupport::Concern included do include Virtus.model attribute :document_class, Class attribute :index, String, default: lambda { |search, attr| Gummi::DbLayer::DefaultIndex.name } attribute :type, String attribute :page, Gummi::DbLayer::Fields::PositiveInteger, default: 1 attribute :per_page, Gummi::DbLayer::Fields::PositiveInteger, default: 300 attribute :options, Hash, default: {} end def to_client_args args = { index: index, from: from, size: size, lenient: true, } args[:type] = type if type args.merge options end def execute Gummi::DbLayer::Document::Search::Result.new client.search(to_client_args), document_class, per_page, page rescue Faraday::Error::ConnectionFailed Gummi::DbLayer::Document::Search::Result.new nil, document_class, per_page, page end private def size per_page end def from per_page * (page - 1) end def client Gummi::API.client end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems