class DbToFile::Unloader::Table::Record
Public Class Methods
new(row, table)
click to toggle source
# File lib/db_to_file/unloader.rb, line 66 def initialize(row, table) @row = row @table = table end
Public Instance Methods
fields_to_files()
click to toggle source
# File lib/db_to_file/unloader.rb, line 71 def fields_to_files build_directory normalized_hash = DbToFile::ValuesNormalizer::ObjectToHash.new(@row).normalize normalized_hash.except(*ignore_columns).each_pair do |field_name, value| Field.new(field_name, self).write_value(value) end end
Private Instance Methods
base_dir()
click to toggle source
# File lib/db_to_file/unloader.rb, line 89 def base_dir "db/db_to_file/#{table_name}/#{row_name}" end
build_directory()
click to toggle source
# File lib/db_to_file/unloader.rb, line 81 def build_directory FileUtils.mkdir_p(base_dir) end
config()
click to toggle source
# File lib/db_to_file/unloader.rb, line 111 def config Config.instance end
config_directory_prefix()
click to toggle source
# File lib/db_to_file/unloader.rb, line 103 def config_directory_prefix config.directory_prefix(table_name) end
directory_prefix()
click to toggle source
# File lib/db_to_file/unloader.rb, line 97 def directory_prefix if config_directory_prefix.present? (@row.send(config_directory_prefix) || '').parameterize end end
ignore_columns()
click to toggle source
# File lib/db_to_file/unloader.rb, line 85 def ignore_columns config.ignore_columns(table_name) end
row_name()
click to toggle source
# File lib/db_to_file/unloader.rb, line 93 def row_name [directory_prefix, @row.id.to_s].compact.reject(&:empty?).join('_') end
table_name()
click to toggle source
# File lib/db_to_file/unloader.rb, line 107 def table_name @row.class.table_name end