Class: SQL::Statement::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/sql/statement.rb

Instance Method Summary collapse

Instance Method Details

#accept(visitor) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sql/statement.rb', line 6

def accept(visitor)
  klass = self.class.ancestors.find do |ancestor|
    visitor.respond_to?("visit_#{demodulize(ancestor.name)}")
  end

  if klass
    visitor.__send__("visit_#{demodulize(klass.name)}", self)
  else
    raise "No visitor for #{self.class.name}"
  end
end

#to_sqlObject


18
19
20
# File 'lib/sql/statement.rb', line 18

def to_sql
  SQLVisitor.new.visit(self)
end