Class: Prequel::Relations::Selection
- Defined in:
- lib/prequel/relations/selection.rb
Instance Attribute Summary collapse
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
Instance Method Summary collapse
- #columns ⇒ Object
-
#initialize(operand, predicate) ⇒ Selection
constructor
A new instance of Selection.
- #visit(query) ⇒ Object
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
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
4 5 6 |
# File 'lib/prequel/relations/selection.rb', line 4 def operand @operand end |
#predicate ⇒ Object (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
#columns ⇒ Object
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 |