Sha256: 93231c0bbc409e40dfa52924493f1a11aad22932fa2e327df671a5602db1499a
Contents?: true
Size: 1.64 KB
Versions: 5
Compression:
Stored size: 1.64 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] @sort_column = if @table.model.columns_hash[@label_method.to_s] @label_method elsif @table.model.columns_hash[@name.to_s] @name 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 = '' code = if child if @options[:children].is_a?(FalseClass) 'nil' else "#{record}.#{table.options[:children]}.#{@options[:children] || @label_method}" end else "#{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
5 entries across 5 versions & 1 rubygems