Class: Storey::RubyDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/storey/ruby_dumper.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RubyDumper

Returns a new instance of RubyDumper.



6
7
8
9
# File 'lib/storey/ruby_dumper.rb', line 6

def initialize(options={})
  default_file_path = File.join(Rails.root, 'db', 'schema.rb')
  @file = options[:file] || default_file_path
end

Instance Method Details

#dumpObject



11
12
13
14
15
16
# File 'lib/storey/ruby_dumper.rb', line 11

def dump
  File.open(@file, "w:utf-8") do |file|
    ::ActiveRecord::Base.establish_connection(Rails.env.to_sym)
    ::ActiveRecord::SchemaDumper.dump(::ActiveRecord::Base.connection, file)
  end
end