Class: Prequel::Relations::Selection

Inherits:
Relation
  • Object
show all
Defined in:
lib/prequel/relations/selection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Relation

#find, #get_column, #join, #project, #query, #singular_table_ref, #table_ref, #to_relation, #where

Constructor Details

#initialize(operand, predicate) ⇒ Selection

Returns a new instance of Selection.



6
7
8
9
# File 'lib/prequel/relations/selection.rb', line 6

def initialize(operand, predicate)
  @operand = operand
  @predicate = resolve(predicate.to_predicate)
end

Instance Attribute Details

#operandObject (readonly)

Returns the value of attribute operand.



4
5
6
# File 'lib/prequel/relations/selection.rb', line 4

def operand
  @operand
end

#predicateObject (readonly)

Returns the value of attribute predicate.



4
5
6
# File 'lib/prequel/relations/selection.rb', line 4

def predicate
  @predicate
end

Instance Method Details

#columnsObject



13
14
15
16
17
# File 'lib/prequel/relations/selection.rb', line 13

def columns
  operand.columns.map do |column|
    derive(column)
  end
end

#visit(query) ⇒ Object



19
20
21
22
# File 'lib/prequel/relations/selection.rb', line 19

def visit(query)
  operand.visit(query)
  query.add_condition(predicate.resolve_in_query(query))
end