Class: DbSeeder::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/db_seeder/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ Generator

Returns a new instance of Generator.



9
10
11
12
# File 'lib/db_seeder/generator.rb', line 9

def initialize(config, options = {})
  @config = config
  @options = options
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/db_seeder/generator.rb', line 7

def config
  @config
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/db_seeder/generator.rb', line 7

def options
  @options
end

Instance Method Details

#generate(table_name = nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/db_seeder/generator.rb', line 14

def generate(table_name = nil)
  tables = table_name ? [table_name] : fetch_tables
  
  tables.each do |table|
    export_table(table)
  end
end