Class: Departure::AlterArgument
- Inherits:
-
Object
- Object
- Departure::AlterArgument
- Defined in:
- lib/departure/alter_argument.rb
Overview
Represents the ‘–alter’ argument of Percona’s pt-online-schema-change See www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html
Constant Summary collapse
- ALTER_TABLE_REGEX =
/\AALTER TABLE [^\s]*[\n]* /
Instance Attribute Summary collapse
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
-
#initialize(statement) ⇒ AlterArgument
constructor
Constructor.
-
#to_s ⇒ Object
Returns the ‘–alter’ pt-online-schema-change argument as a string.
Constructor Details
#initialize(statement) ⇒ AlterArgument
Constructor
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/departure/alter_argument.rb', line 15 def initialize(statement) @statement = statement match = statement.match(ALTER_TABLE_REGEX) raise InvalidAlterStatement unless match # Separates the ALTER TABLE from the table_name # # Removes the grave marks, if they are there, so we can get the table_name @table_name = String(match) .split(' ')[2] .delete('`') end |
Instance Attribute Details
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
9 10 11 |
# File 'lib/departure/alter_argument.rb', line 9 def table_name @table_name end |
Instance Method Details
#to_s ⇒ Object
Returns the ‘–alter’ pt-online-schema-change argument as a string. See www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html
30 31 32 |
# File 'lib/departure/alter_argument.rb', line 30 def to_s "--alter \"#{parsed_statement}\"" end |