Sha256: 081dfe1f4eadf4ab0168c82de9ba167b9830cdc6f7b75ee14f5836f0307ff788

Contents?: true

Size: 762 Bytes

Versions: 4

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true
require 'arel/collectors/sql_string'

module Arel
  class TreeManager
    include Arel::FactoryMethods

    attr_reader :ast

    def initialize
      @ctx = nil
    end

    def to_dot
      collector = Arel::Collectors::PlainString.new
      collector = Visitors::Dot.new.accept @ast, collector
      collector.value
    end

    def to_sql engine = Table.engine
      collector = Arel::Collectors::SQLString.new
      collector = engine.connection.visitor.accept @ast, collector
      collector.value
    end

    def initialize_copy other
      super
      @ast = @ast.clone
    end

    def where expr
      if Arel::TreeManager === expr
        expr = expr.ast
      end
      @ctx.wheres << expr
      self
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
spiral_form-0.1.1 vendor/bundle/gems/arel-9.0.0/lib/arel/tree_manager.rb
spiral_form-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/tree_manager.rb
nullifyable-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/tree_manager.rb
arel-9.0.0 lib/arel/tree_manager.rb