Class: SQLTree::Node::Source
Instance Attribute Summary collapse
-
#joins ⇒ Object
Returns the value of attribute joins.
-
#table_reference ⇒ Object
Returns the value of attribute table_reference.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(table_reference, joins = []) ⇒ Source
constructor
A new instance of Source.
- #table ⇒ Object
- #table_alias ⇒ Object
- #to_sql ⇒ Object
Methods inherited from Base
[], #inspect, #quote_str, #quote_var
Constructor Details
#initialize(table_reference, joins = []) ⇒ Source
Returns a new instance of Source.
7 8 9 |
# File 'lib/sql_tree/node/source.rb', line 7 def initialize(table_reference, joins = []) @table_reference, @joins = table_reference, joins end |
Instance Attribute Details
#joins ⇒ Object
Returns the value of attribute joins.
5 6 7 |
# File 'lib/sql_tree/node/source.rb', line 5 def joins @joins end |
#table_reference ⇒ Object
Returns the value of attribute table_reference.
5 6 7 |
# File 'lib/sql_tree/node/source.rb', line 5 def table_reference @table_reference end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
25 26 27 |
# File 'lib/sql_tree/node/source.rb', line 25 def ==(other) other.table_reference = self.table_reference && other.joins == self.joins end |
#table ⇒ Object
11 12 13 |
# File 'lib/sql_tree/node/source.rb', line 11 def table table_reference.table end |
#table_alias ⇒ Object
15 16 17 |
# File 'lib/sql_tree/node/source.rb', line 15 def table_alias table_reference.table_alias end |
#to_sql ⇒ Object
19 20 21 22 23 |
# File 'lib/sql_tree/node/source.rb', line 19 def to_sql sql = table_reference.to_sql sql << ' ' << joins.map { |j| j.to_sql }.join(' ') if joins.any? return sql end |