Sha256: 104a1b976ec8c62d32a3e2996100fd4aeac672ac54b41fe359961698ab3ac1ce
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
class Card module Query # support the use of the card_references table in CQL class ReferenceQuery < AbstractQuery def table "card_references" end def table_prefix "cr" end def referer hash add_conditions :referer_id, hash end def referee hash add_conditions :referee_id, hash end def add_conditions outfield, hash add_reftype_condition hash[:reftype] add_outfield_condition outfield, hash[:card] end def add_outfield_condition outfield, outcard if outcard == "_none" non_outfield elsif (op_and_id = op_and_id_or_ids_from_val(outcard)) outfield_id outfield, op_and_id else tie :card, outcard, from: outfield end end def non_outfield add_condition "#{fld :is_present} = 0" end def outfield_id outfield, op_and_id add_condition "#{fld(outfield)} #{op_and_id}" end def add_reftype_condition reftype return unless reftype.present? reftype = Array.wrap reftype operator = (reftype.size == 1 ? "=" : "IN") quoted_letters = reftype.map { |letter| "'#{letter}'" } * ", " add_condition "#{fld(:ref_type)} #{operator} (#{quoted_letters})" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems