Class: Unschema::Base
- Inherits:
-
Struct
- Object
- Struct
- Unschema::Base
- Defined in:
- lib/unschema/base.rb
Instance Attribute Summary collapse
-
#migrations_path ⇒ Object
Returns the value of attribute migrations_path.
-
#schema_file ⇒ Object
Returns the value of attribute schema_file.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#migrations_path ⇒ Object
Returns the value of attribute migrations_path
2 3 4 |
# File 'lib/unschema/base.rb', line 2 def migrations_path @migrations_path end |
#schema_file ⇒ Object
Returns the value of attribute schema_file
2 3 4 |
# File 'lib/unschema/base.rb', line 2 def schema_file @schema_file end |
#verbose ⇒ Object
Returns the value of attribute verbose
2 3 4 |
# File 'lib/unschema/base.rb', line 2 def verbose @verbose end |
Class Method Details
.process!(*args) ⇒ Object
3 4 5 |
# File 'lib/unschema/base.rb', line 3 def self.process!(*args) new(*args).process end |
Instance Method Details
#process ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/unschema/base.rb', line 11 def process load schema_file @version = ActiveRecord::Schema.intermediator.version calls_for_tables = Hash.new{|hash, key| hash[key] = []} ActiveRecord::Schema.intermediator.calls.each do |call| table_name = call.args.first.to_s if [:create_table, :add_index].include?(call.name) raise "Don't now how to process #{call.name.inspect}" unless table_name calls_for_tables[table_name] << call end puts "Found #{calls_for_tables.keys.size} tables" if verbose? calls_for_tables.sort.each do |table_name, calls| puts " Dumping #{table_name.inspect}" if verbose? dump_table_calls table_name, calls end puts "Done" if verbose? end |
#verbose? ⇒ Boolean
7 8 9 |
# File 'lib/unschema/base.rb', line 7 def verbose? !!verbose end |