Sha256: ad2e0f4e06bbcda3a8e28cf1c94a670c9aa52ff4bd1b2cc53fd968ce3cfae63c
Contents?: true
Size: 980 Bytes
Versions: 5
Compression:
Stored size: 980 Bytes
Contents
module MightyGrid class Column attr_reader :display_property, :attribute, :attrs, :th_attrs, :options, :title attr_accessor :render_value def initialize(attr_or_options=nil, options=nil, &block) @attrs = {} if block_given? @options = attr_or_options @display_property = :block @render_value = block else @options = options @attribute = attr_or_options @display_property = :attr @render_value = attribute end @attrs = options[:html] if options && options.has_key?(:html) @th_attrs = options[:th_html] if options && options.has_key?(:th_html) @title = options[:title] || '' end def render(record) case @display_property when :attr return record[@render_value] when :block value = @render_value.call(record) return ERB::Util.h(value).to_s.html_safe else # raise end end end end
Version data entries
5 entries across 5 versions & 1 rubygems