Class: Card::Query::Reference
Constant Summary collapse
- 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 ] }
Instance Attribute Summary collapse
-
#cardquery ⇒ Object
Returns the value of attribute cardquery.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#infield ⇒ Object
Returns the value of attribute infield.
-
#outfield ⇒ Object
Returns the value of attribute outfield.
Instance Method Summary collapse
-
#initialize(key, val, parent) ⇒ Reference
constructor
A new instance of Reference.
- #table_alias ⇒ Object
Constructor Details
#initialize(key, val, parent) ⇒ Reference
Returns a new instance of Reference.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/card/query/reference.rb', line 27 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 |
Instance Attribute Details
#cardquery ⇒ Object
Returns the value of attribute cardquery.
20 21 22 |
# File 'lib/card/query/reference.rb', line 20 def cardquery @cardquery end |
#conditions ⇒ Object
Returns the value of attribute conditions.
20 21 22 |
# File 'lib/card/query/reference.rb', line 20 def conditions @conditions end |
#infield ⇒ Object
Returns the value of attribute infield.
20 21 22 |
# File 'lib/card/query/reference.rb', line 20 def infield @infield end |
#outfield ⇒ Object
Returns the value of attribute outfield.
20 21 22 |
# File 'lib/card/query/reference.rb', line 20 def outfield @outfield end |
Instance Method Details
#table_alias ⇒ Object
22 23 24 |
# File 'lib/card/query/reference.rb', line 22 def table_alias @table_alias ||= "cr#{@parent.table_id force=true}" end |