Method: ActiveList::Definition::DataColumn#exporting_datum_code

Defined in:
lib/active_list/definition/data_column.rb

#exporting_datum_code(record = 'record_of_the_death', noview = false) ⇒ Object

Code for exportation



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_list/definition/data_column.rb', line 15

def exporting_datum_code(record = 'record_of_the_death', noview = false)
  datum = datum_code(record)
  if datatype == :boolean
    datum = "(#{datum} ? ::I18n.translate('list.export.true_value') : ::I18n.translate('list.export.false_value'))"
  elsif datatype == :date
    datum = "(#{datum}.nil? ? '' : #{datum}.l)"
  elsif datatype == :decimal && !noview
    currency = currency_for(record)
    datum = "(#{datum}.nil? ? '' : #{datum}.l(#{'currency: ' + currency.inspect if currency}))"
  elsif @name.to_s.match(/(^|\_)currency$/) && datatype == :string
    datum = "(Nomen::Currencies[#{datum}] ? Nomen::Currencies[#{datum}].human_name : '')"
  elsif @name.to_s.match(/(^|\_)country$/) && datatype == :string
    datum = "(Nomen::Countries[#{datum}] ? Nomen::Countries[#{datum}].human_name : '')"
  elsif @name.to_s.match(/(^|\_)language$/) && datatype == :string
    datum = "(Nomen::Languages[#{datum}] ? Nomen::Languages[#{datum}].human_name : '')"
  elsif enumerize?
    datum = "(#{datum}.nil? ? '' : #{datum}.text)"
  end
  datum
end