Class: Backhoe::Dump

Inherits:
Struct
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/backhoe/dump.rb

Defined Under Namespace

Classes: SanitizedDatabase

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Dump

Returns a new instance of Dump.



7
8
9
10
11
# File 'lib/backhoe/dump.rb', line 7

def initialize *args
  super
  self.skip_tables ||= []
  self.skip_columns ||= {}
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database

Returns:

  • (Object)

    the current value of database



4
5
6
# File 'lib/backhoe/dump.rb', line 4

def database
  @database
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/backhoe/dump.rb', line 4

def path
  @path
end

#skip_columnsObject

Returns the value of attribute skip_columns

Returns:

  • (Object)

    the current value of skip_columns



4
5
6
# File 'lib/backhoe/dump.rb', line 4

def skip_columns
  @skip_columns
end

#skip_tablesObject

Returns the value of attribute skip_tables

Returns:

  • (Object)

    the current value of skip_tables



4
5
6
# File 'lib/backhoe/dump.rb', line 4

def skip_tables
  @skip_tables
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/backhoe/dump.rb', line 13

def call
  if skip_tables.any?
    raise NotImplementedError if database.postgresql?
  end
  if skip_columns.any?
    raise NotImplementedError if database.postgresql?
    SanitizedDatabase.new(skip_columns, path).dump do |tables|
      self.skip_tables += tables
      dump
    end
  else
    dump
  end
end