Sha256: e5081ffdc43f98e3af3f9d238aa8395881b1db1c7b36959811428ab0781b4eb8
Contents?: true
Size: 1.22 KB
Versions: 14
Compression:
Stored size: 1.22 KB
Contents
class Card::Query class Reference DEFINITIONS = { # syntax: # wql query key => [ direction, {reference_type} ] # direction = :out | :in # reference_type = 'L' | 'I' | 'P' refer_to: [ :out, 'L','I' ], referred_to_by: [ :in, 'L','I' ], link_to: [ :out, 'L' ], linked_to_by: [ :in, 'L' ], include: [ :out, 'I' ], included_by: [ :in, 'I' ] } FIELDMAP = { out: [ :referer_id, :referee_id ], in: [ :referee_id, :referer_id ] } attr_accessor :conditions, :cardquery, :infield, :outfield def table_alias @table_alias ||= "cr#{@parent.table_id force=true}" end def initialize key, val, parent key, val, @parent = key, val, parent @conditions = [] direction, *reftype = DEFINITIONS[ key.to_sym ] @infield, @outfield = FIELDMAP[ direction ] if reftype.present? operator = (reftype.size==1 ? '=' : 'IN') quoted_letters = reftype.map { |letter| "'#{letter}'" } * ', ' @conditions << "ref_type #{operator} (#{quoted_letters})" end if val == '_none' @conditions << "present = 0" else @cardquery = val end self end end end
Version data entries
14 entries across 14 versions & 1 rubygems