Files
grecia/app/models/concerns/download_settings/budget_investment_csv.rb
Javi Martín f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00

29 lines
700 B
Ruby

module DownloadSettings
module BudgetInvestmentCsv
extend ActiveSupport::Concern
def get_association_attribute_names
["author_name", "author_email"]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Budget::Investment",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(budgets, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
budgets.each do |budget|
csv << attributes.map { |attr| budget.send(attr) }
end
end
end
end
end