Sha256: f5fe2d8a6c021d506fe82a36d3b4ba4a4a4d188bcd6d737220ad1228bb074927
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
module ActiveList module Definition class AttributeColumn < DataColumn attr_reader :column, :label_method, :sort_column, :computation_method def initialize(table, name, options = {}) super(table, name, options) @label_method = (options[:label_method] || @name).to_sym unless @sort_column = options[:sort] if @table.model.columns_hash[@label_method.to_s] @sort_column = @label_method elsif @table.model.columns_hash[@name.to_s] @sort_column = @name else @sort_column = nil end end @computation_method = options[:on_select] @column = @table.model.columns_hash[@label_method.to_s] end # Code for rows def datum_code(record = 'record_of_the_death', child = false) code = '' if child if @options[:children].is_a?(FalseClass) code = 'nil' else code = "#{record}.#{table.options[:children]}.#{@options[:children] || @label_method}" end else code = "#{record}.#{@label_method}" end code.c end # Returns the class name of the used model def class_name table.model.name end def sortable? !sort_column.nil? end def computable? !computation_method.nil? end def enumerize? table.model.send(@label_method).send(:values) return true rescue return false end def sort_expression "#{@table.model.table_name}.#{@sort_column}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems