Class: DroppableTable::SchemaParser

Inherits:
Object
  • Object
show all
Defined in:
lib/droppable_table/schema_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_path) ⇒ SchemaParser

Returns a new instance of SchemaParser.



7
8
9
10
# File 'lib/droppable_table/schema_parser.rb', line 7

def initialize(schema_path)
  @schema_path = schema_path
  @format = detect_format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/droppable_table/schema_parser.rb', line 5

def format
  @format
end

#schema_pathObject (readonly)

Returns the value of attribute schema_path.



5
6
7
# File 'lib/droppable_table/schema_parser.rb', line 5

def schema_path
  @schema_path
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/droppable_table/schema_parser.rb', line 12

def parse
  case format
  when :ruby
    parse_ruby_schema
  when :sql
    parse_sql_schema
  else
    raise SchemaNotFoundError, "Unknown schema format: #{schema_path}"
  end
end