Class: Arel::TreeManager
- Includes:
- FactoryMethods
- Defined in:
- activerecord/lib/arel/tree_manager.rb
Direct Known Subclasses
Defined Under Namespace
Modules: StatementMethods
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
Instance Method Summary collapse
-
#initialize(table = nil) ⇒ TreeManager
constructor
A new instance of TreeManager.
- #initialize_copy(other) ⇒ Object
- #to_dot ⇒ Object
- #to_sql(engine = nil) ⇒ Object
Methods included from FactoryMethods
#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
#initialize(table = nil) ⇒ TreeManager
Returns a new instance of TreeManager.
47 48 49 |
# File 'activerecord/lib/arel/tree_manager.rb', line 47 def initialize(table = nil) @table = table end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
45 46 47 |
# File 'activerecord/lib/arel/tree_manager.rb', line 45 def ast @ast end |
Instance Method Details
#initialize_copy(other) ⇒ Object
70 71 72 73 |
# File 'activerecord/lib/arel/tree_manager.rb', line 70 def initialize_copy(other) super @ast = @ast.clone end |
#to_dot ⇒ Object
51 52 53 54 55 |
# File 'activerecord/lib/arel/tree_manager.rb', line 51 def to_dot collector = Arel::Collectors::PlainString.new collector = Visitors::Dot.new.accept @ast, collector collector.value end |
#to_sql(engine = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'activerecord/lib/arel/tree_manager.rb', line 57 def to_sql(engine = nil) unless engine table = @table.is_a?(Nodes::JoinSource) ? @table.left : @table engine = table&.klass || Table.engine end collector = Arel::Collectors::SQLString.new engine.with_connection do |connection| connection.visitor.accept(@ast, collector).value end end |