Module: Hakoy::FileAppender::Csv
Instance Method Summary collapse
Instance Method Details
#call(file_path, row_hash, opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hakoy/file_appender/csv.rb', line 6 def call(file_path, row_hash, opts={}) uid_key = opts.fetch(:uid_key) { 'id' } file_exists = File.exists?(file_path) if file_exists when_not_a_duplicate(file_path, row_hash, uid_key) do append_to_csv_file(file_path, row_hash.values) end else append_to_csv_file(file_path, row_hash.keys, row_hash.values) end end |