lib/brillo/scrubber.rb in brillo-1.1.0 vs lib/brillo/scrubber.rb in brillo-1.1.1
- old
+ new
@@ -44,20 +44,23 @@
File.open(config.dump_path, "a") do |sql_file|
sql_file.puts(adapter.header)
klass_association_map.each do |klass, options|
begin
klass = deserialize_class(klass)
- tactic = deserialize_tactic(options)
+ tactic = deserialize_tactic(klass, options)
rescue ConfigParseError => e
logger.error "Error in brillo.yml: #{e.message}"
next
end
- associations = options.fetch("associations", [])
+ associations = options.fetch(:associations, [])
explore_class(klass, tactic, associations) do |insert|
sql_file.puts(insert)
end
end
+ ActiveRecord::Base.descendants.each do |klass|
+ sql_file.puts(adapter.table_footer(klass))
+ end
sql_file.puts(adapter.footer)
end
end
private
@@ -95,16 +98,16 @@
end
end
end
def deserialize_class(klass)
- klass.camelize.constantize
+ klass.to_s.camelize.constantize
rescue
- raise Config::ConfigParseError, "Could not process class '#{klass}'"
+ raise ConfigParseError, "Could not process class '#{klass}'"
end
- def deserialize_tactic(options)
- options.fetch("tactic").to_sym
+ def deserialize_tactic(klass, options)
+ options.fetch(:tactic).to_sym
rescue KeyError
raise ConfigParseError, "Tactic not specified for class #{klass}"
end
end
end