Sha256: 383c3f2c082f58f1cabb548da58e826f6f064daa8af1d147407daf1782ffac3b
Contents?: true
Size: 1.1 KB
Versions: 9
Compression:
Stored size: 1.1 KB
Contents
module Eco module API module UseCases class DefaultCases class ToCsvCase < BaseCase def process @cases.define("to-csv", type: :export) do |people, session, options| unless people && !people.empty? session.logger.warn("No source people to create the file... aborting!") next false end unless file = options[:file] session.logger.error("Destination file not specified") next false end session.logger.info("going to create file: #{file}") CSV.open(file, "w") do |csv| deps = {"supervisor_id" => {people: people}} entry = session.new_entry(people.first, dependencies: deps) csv << entry.to_hash.keys people.each do |person| csv << session.new_entry(person, dependencies: deps).to_hash.values end end true end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems