Class: Trains::Visitor::Schema

Inherits:
Base
  • Object
show all
Defined in:
lib/trains/visitor/schema.rb

Overview

Visitor that parses DB migration and associates them with Rails models

Instance Method Summary collapse

Constructor Details

#initializeSchema

Returns a new instance of Schema.



17
18
19
20
21
# File 'lib/trains/visitor/schema.rb', line 17

def initialize
  @models = []
  @columns = []
  @is_versioned = false
end

Instance Method Details

#on_block(node) ⇒ Object



23
24
25
26
27
28
# File 'lib/trains/visitor/schema.rb', line 23

def on_block(node)
  is_schema = versioned_schema?(node) || unversioned_schema?(node)
  return unless is_schema

  process_schema_body(node)
end

#resultObject



30
31
32
# File 'lib/trains/visitor/schema.rb', line 30

def result
  @models
end