Class: Screamers::SchemaCollector
- Inherits:
-
Object
- Object
- Screamers::SchemaCollector
- Defined in:
- lib/screamers/schema_collector.rb
Instance Method Summary collapse
- #collect_schema ⇒ Object
-
#initialize(old_column_type, new_column_type) ⇒ SchemaCollector
constructor
A new instance of SchemaCollector.
Constructor Details
#initialize(old_column_type, new_column_type) ⇒ SchemaCollector
Returns a new instance of SchemaCollector.
5 6 7 8 |
# File 'lib/screamers/schema_collector.rb', line 5 def initialize(old_column_type, new_column_type) @old_column_type = old_column_type.to_sym @new_column_type = new_column_type.to_sym end |
Instance Method Details
#collect_schema ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/screamers/schema_collector.rb', line 12 def collect_schema tables = ActiveRecord::Base.connection.tables tables.delete('ar_internal_metadata') @target_tables = tables.each_with_object({}) {|table, target| columns = Module.const_get(table.classify).columns rescue next target_columns = columns.select {|column| column.type == @old_column_type } unless (columns = target_columns.map(&:name)).empty? target[table] = columns end } end |