class DumpTruck::SchemaConfiguration
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 5 def initialize(name) @name = name @tables = Hash.new(TableConfiguration.new{truncate}) @target_path = 'tmp' @target_name_generator = proc{|schema| schema} instance_eval(&Proc.new) if block_given? end
Public Instance Methods
==(other)
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 47 def ==(other) name == other.name && target_path == other.target_path && tables == other.tables end
table(name, &block)
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 34 def table(name, &block) name = name.to_s @tables[name] = TableConfiguration.new(name, &block) end
table_config_for(table)
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 43 def table_config_for(table) @tables[table.to_s] end
table_default()
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 26 def table_default if block_given? @tables.default = TableConfiguration.new(&Proc.new) else @tables.default end end
tables()
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 39 def tables @tables.values end
target()
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 22 def target File.join(@target_path, @target_name_generator.call(@name) + '.sql.gz') end
target_name()
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 18 def target_name @target_name_generator = Proc.new end
target_path(target_path = nil)
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 14 def target_path(target_path = nil) @target_path = target_path || @target_path end
to_s()
click to toggle source
# File lib/dump_truck/schema_configuration.rb, line 51 def to_s "<DumpTruck::SchemaConfiguration(#{name}) target:#{target} (#{tables.map(&:to_s).join(', ')})>" end