Class: SqlTools::SchemaVisitor

Inherits:
TreeStand::Visitor
  • Object
show all
Defined in:
lib/sql_tools/schema_visitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ SchemaVisitor

Returns a new instance of SchemaVisitor.



5
6
7
8
# File 'lib/sql_tools/schema_visitor.rb', line 5

def initialize(node)
  super(node)
  @schema = Schema.new
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



3
4
5
# File 'lib/sql_tools/schema_visitor.rb', line 3

def schema
  @schema
end

Instance Method Details

#on_column_definition(node) ⇒ Object



14
15
16
# File 'lib/sql_tools/schema_visitor.rb', line 14

def on_column_definition(node)
  @schema.columns << ColumnDefinition.new(node)
end

#on_constraint(node) ⇒ Object



18
19
20
# File 'lib/sql_tools/schema_visitor.rb', line 18

def on_constraint(node)
  @schema.constraints << Constraint.from(node)
end

#on_create_table(node) ⇒ Object



10
11
12
# File 'lib/sql_tools/schema_visitor.rb', line 10

def on_create_table(node)
  @schema.create_table = node
end