Class: SimpleMySQLPartitioning::Executor
- Inherits:
-
Object
- Object
- SimpleMySQLPartitioning::Executor
- Defined in:
- lib/simple_mysql_partitioning/executor.rb
Instance Method Summary collapse
- #add(less_than_value) ⇒ Object
- #drop ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(klass, partition_name) ⇒ Executor
constructor
A new instance of Executor.
- #reorganize(less_than_value, reorganize_partition_name) ⇒ Object
Constructor Details
#initialize(klass, partition_name) ⇒ Executor
Returns a new instance of Executor.
6 7 8 9 10 |
# File 'lib/simple_mysql_partitioning/executor.rb', line 6 def initialize(klass, partition_name) @klass = klass @table_name = @klass.table_name @partition_name = partition_name end |
Instance Method Details
#add(less_than_value) ⇒ Object
12 13 14 15 16 |
# File 'lib/simple_mysql_partitioning/executor.rb', line 12 def add(less_than_value) return if exist? add_partition_sql = SQL.add_sql(@table_name, @partition_name, less_than_value) @klass.connection.execute(add_partition_sql) end |
#drop ⇒ Object
35 36 37 38 |
# File 'lib/simple_mysql_partitioning/executor.rb', line 35 def drop return unless exist? @klass.connection.execute(SQL.parge_sql(@table_name, @partition_name)) end |
#exist? ⇒ Boolean
29 30 31 32 33 |
# File 'lib/simple_mysql_partitioning/executor.rb', line 29 def exist? @klass.connection.select_all( SQL.exist_sql(@table_name, @partition_name) ).to_hash.present? end |
#reorganize(less_than_value, reorganize_partition_name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/simple_mysql_partitioning/executor.rb', line 18 def reorganize(less_than_value, reorganize_partition_name) return if exist? @klass.connection.execute( SQL.reorganize_sql( @table_name, @partition_name, less_than_value, reorganize_partition_name ) ) end |