Sha256: 23519ba759010c2d2eb775c8456f5dce0eabd3ad1d90c63ce1417e496f355bbf
Contents?: true
Size: 625 Bytes
Versions: 75
Compression:
Stored size: 625 Bytes
Contents
module Pageflow # @api private class UserNameQuery < ApplicationQuery class Scope < Scope def initialize(term, scope) @term = term @scope = scope end def resolve scope.where(word_conditions(term)) end private attr_reader :term, :scope def word_conditions(term) term.split(' ').map { |word| word_condition(word) }.join(' AND ') end def word_condition(word) sanitize_sql('(users.first_name LIKE :word OR users.last_name LIKE :word)', word: "%#{word}%") end end end end
Version data entries
75 entries across 75 versions & 1 rubygems