Class: SchemaPlus::Core::SqlStruct::Table
- Inherits:
-
Object
- Object
- SchemaPlus::Core::SqlStruct::Table
- Defined in:
- lib/schema_plus/core/sql_struct.rb
Instance Method Summary collapse
Instance Method Details
#assemble ⇒ Object
24 25 26 |
# File 'lib/schema_plus/core/sql_struct.rb', line 24 def assemble ["#{command} #{quotechar}#{name}#{quotechar} (#{body})", ].reject(&:blank?).join(" ") end |
#parse!(sql) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/schema_plus/core/sql_struct.rb', line 7 def parse!(sql) m = sql.strip.match %r{ ^ (?<command>.*\bTABLE\b) \s* (?<quote>['"`])(?<name>\S+)\k<quote> \s* \( \s* (?<body>.*) \s* \) \s* (?<options> \S.*)? $ }xi self.command = m[:command] self.quotechar = m[:quote] self.name = m[:name] self.body = m[:body] self. = m[:options] end |