Class: IndexLifter
- Inherits:
-
Object
- Object
- IndexLifter
- Defined in:
- lib/index_lifter.rb
Constant Summary collapse
- VERSION =
'0.0.3'
- SYSTEM_TABLES =
['schema_migrations'].freeze
Instance Attribute Summary collapse
-
#indexes ⇒ Object
readonly
Returns the value of attribute indexes.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*tables) ⇒ IndexLifter
constructor
A new instance of IndexLifter.
- #without_indexes(&block) ⇒ Object
Constructor Details
#initialize(*tables) ⇒ IndexLifter
Returns a new instance of IndexLifter.
11 12 13 14 15 16 17 18 |
# File 'lib/index_lifter.rb', line 11 def initialize(*tables) @options = tables. @connection = @options[:connection] || ActiveRecord::Base.connection @tables = (tables.empty? ? @connection.tables : tables) - SYSTEM_TABLES @indexes = index_definitions @tables.freeze @indexes.freeze end |
Instance Attribute Details
#indexes ⇒ Object (readonly)
Returns the value of attribute indexes.
5 6 7 |
# File 'lib/index_lifter.rb', line 5 def indexes @indexes end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
5 6 7 |
# File 'lib/index_lifter.rb', line 5 def tables @tables end |
Class Method Details
.without_indexes(*tables, &block) ⇒ Object
7 8 9 |
# File 'lib/index_lifter.rb', line 7 def self.without_indexes(*tables, &block) IndexLifter.new(*tables).without_indexes(&block) end |
Instance Method Details
#without_indexes(&block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/index_lifter.rb', line 20 def without_indexes(&block) lift_indexes(indexes) yield ensure reinstate_indexes(indexes) end |