Sha256: a4f0af61fe25d0b2a0f0603c1aaa23fa03ad5fdc7d4e29880613f8e47e836636
Contents?: true
Size: 657 Bytes
Versions: 14
Compression:
Stored size: 657 Bytes
Contents
module Landable class SearchEngine def initialize(base_scope, filters, options = {}) @scope = base_scope order! options[:order] limit! options[:limit] filter_by!(filters) end def results @scope end def meta { search: { total_results: @scope.count(:all) } } end def filter_by!(filters) raise NotImplementedError end def order!(order) @scope = @scope.order(order) if order end def limit!(limit) @scope = @scope.limit(limit) if limit end protected def as_array(value) array = Array(value) array if array.any? end end end
Version data entries
14 entries across 14 versions & 1 rubygems