module Card::Query::CardQuery::RelationalAttributes

interpret CQL attributes that relate multiple cards each method below corresponds to a relational CQL term

NOTE: methods using “restrict” can be executed without tying in an additional query if the val in question can be reduced to an id.

Public Instance Methods

created_by(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 56
def created_by val
  restrict :creator_id, val
end
creator_of(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 52
def creator_of val
  tie :card, val, to: :creator_id
end
edited_by(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 36
def edited_by val
  tie_action :action_by, val
end
editor_of(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 28
def editor_of val
  tie_act :action_on, val
end
last_edited_by(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 48
def last_edited_by val
  restrict :updater_id, val
end
last_editor_of(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 44
def last_editor_of val
  tie :card, val, to: :updater_id
end
left(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 20
def left val
  restrict :left_id, val
end
left_plus(val) click to toggle source

~~~~~~ PLUS RELATIONAL

# File lib/card/query/card_query/relational_attributes.rb, line 62
def left_plus val
  junction val, :left, :right_id
end
part(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 15
def part val
  right_val = val.is_a?(Integer) ? val : val.clone
  any(left: val, right: right_val)
end
plus(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 70
def plus val
  any(left_plus: val, right_plus: val.deep_clone)
end
right(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 24
def right val
  restrict :right_id, val
end
right_plus(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 66
def right_plus val
  junction val, :right, :left_id
end
type(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 11
def type val
  restrict :type_id, val
end
updated_by(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 40
def updated_by val
  tie_action :update_action_by, val
end
updater_of(val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 32
def updater_of val
  tie_act :update_action_on, val
end

Private Instance Methods

junction(val, side, field) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 84
def junction val, side, field
  tie :card, junction_val(val, side), to: field
end
junction_val(val, side) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 88
def junction_val val, side
  part_clause, junction_clause = val.is_a?(Array) ? val : [val, {}]
  clause_to_hash(junction_clause).merge side => part_clause
end
tie_act(action, val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 80
def tie_act action, val
  tie :act, { action => val }, { to: :actor_id }
end
tie_action(action, val) click to toggle source
# File lib/card/query/card_query/relational_attributes.rb, line 76
def tie_action action, val
  tie :action, { action => val }, { to: :card_id }
end