Sha256: 96f714ef0f63c5ea940af0d144bb08ced67d07d75a89edc4e6bdeab3828c13a2
Contents?: true
Size: 553 Bytes
Versions: 16
Compression:
Stored size: 553 Bytes
Contents
# frozen_string_literal: true class Gutentag::TaggedWith::Query def initialize(model, values, match) @model = model @values = Array values @match = match end def call model.where "#{model_id} IN (#{query.to_sql})" end private attr_reader :model, :values, :match def model_id "#{model.quoted_table_name}.#{model.quoted_primary_key}" end def query return taggable_ids_query if match == :any || values.length == 1 taggable_ids_query.having("COUNT(*) = #{values.length}").group(:taggable_id) end end
Version data entries
16 entries across 16 versions & 1 rubygems