Sha256: fea77d421cf790bce46bc888491edda97ba844ab54ab025266e4fd1b10f2a696
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
class Datagrid::Columns::Column attr_accessor :grid, :options, :block, :name def initialize(grid, name, options = {}, &block) self.grid = grid self.name = name.to_sym self.options = options self.block = block end def value(model, report) value_for(model, report) end def value_for(model, report) if self.block.arity == 1 self.block.call(model) elsif self.block.arity == 2 self.block.call(model, report) else model.instance_eval(&self.block) end end def format self.options[:format] end def label self.options[:label] end def header self.options[:header] || I18n.translate(self.name, :scope => "reports.#{self.grid.param_name}.columns", :default => self.name.to_s.humanize ) end def order if options.has_key?(:order) self.options[:order] else grid.driver.default_order(grid.scope, name) end end def order_desc return nil unless order self.options[:order_desc] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.4.0 | lib/datagrid/columns/column.rb |