Sha256: a3a43dede37d428f79fd7da56e2759eeaba7031d943d121b6d2027d37f564d8e
Contents?: true
Size: 733 Bytes
Versions: 75
Compression:
Stored size: 733 Bytes
Contents
module Pageflow # @api private class EntryTitleOrAccountNameQuery < ApplicationQuery class Scope < Scope def initialize(term, scope) @term = term @scope = scope end def resolve scope .joins(:account) .references(:pageflow_accounts) .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('(pageflow_entries.title LIKE :word OR pageflow_accounts.name LIKE :word)', word: "%#{word}%") end end end end
Version data entries
75 entries across 75 versions & 1 rubygems