class ActiveList::Definition::DataColumn
Constants
- LABELS_COLUMNS
Public Instance Methods
currency_for(record)
click to toggle source
# File lib/active_list/definition/data_column.rb, line 45 def currency_for(record) currency = options[:currency] if currency currency = currency[:body] if currency.is_a?(Hash) currency = :currency if currency.is_a?(TrueClass) currency = "#{record}.#{currency}".c if currency.is_a?(Symbol) end currency end
datatype()
click to toggle source
Returns the data type of the column if the column is in the database
# File lib/active_list/definition/data_column.rb, line 37 def datatype @options[:datatype] || (@column ? @column.type : nil) end
enumerize?()
click to toggle source
# File lib/active_list/definition/data_column.rb, line 41 def enumerize? false end
exportable?()
click to toggle source
Defines if column is exportable
# File lib/active_list/definition/data_column.rb, line 69 def exportable? true end
exporting_datum_code(record = 'record_of_the_death', noview = false)
click to toggle source
Code for exportation
# 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 = "(Onoma::Currency[#{datum}] ? Onoma::Currency[#{datum}].human_name : '')" elsif @name.to_s.match(/(^|\_)country$/) && datatype == :string datum = "(Onoma::Country[#{datum}] ? Onoma::Country[#{datum}].human_name : '')" elsif @name.to_s.match(/(^|\_)language$/) && datatype == :string datum = "(Onoma::Language[#{datum}] ? Onoma::Language[#{datum}].human_name : '')" elsif enumerize? datum = "(#{datum}.nil? ? '' : #{datum}.text)" end datum end
header_code()
click to toggle source
# File lib/active_list/definition/data_column.rb, line 6 def header_code if @options[:label] "#{@options[:label].to_s.strip.inspect}.t(scope: 'labels')".c else "#{@table.model.name}.human_attribute_name(#{@name.inspect})".c end end
limit()
click to toggle source
Returns the size/length of the column if the column is in the database
# File lib/active_list/definition/data_column.rb, line 64 def limit @column[:limit] if @column end
numeric?()
click to toggle source
# File lib/active_list/definition/data_column.rb, line 59 def numeric? %i[decimal integer float numeric].include? datatype end
record_expr(record = 'record_of_the_death')
click to toggle source
Generate code in order to get the (foreign) record of the column
# File lib/active_list/definition/data_column.rb, line 81 def record_expr(record = 'record_of_the_death') record end
sort_expression()
click to toggle source
# File lib/active_list/definition/data_column.rb, line 85 def sort_expression raise NotImplementedError, 'sort_expression must be implemented' end
sortable?()
click to toggle source
Check if a column is sortable
# File lib/active_list/definition/data_column.rb, line 74 def sortable? true # not self.action? and # !options[:through] && !@column.nil? end
state_machine?()
click to toggle source
# File lib/active_list/definition/data_column.rb, line 55 def state_machine? false end