Sha256: bdf4b41ac28544ad15f7b16a3763551156ba54264cead0f7373b75bf3b869955
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Datagrid module ColumnNamesAttribute extend ActiveSupport::Concern included do class_attribute :columns_array self.columns_array = [] datagrid_attribute :column_names do |names| names = Array(names).reject(&:blank?) if names.reject(&:blank?).blank? columns.map(&:name) else names end end end module ClassMethods def column_names_filter filter(:column_names, :enum, :select => proc { |grid| grid.class.columns.map {|c| [c.header, c.name] }}, :multiple => true ) do |value| scoped end end end def columns(*args) options = args.extract_options! column_names = selected_column_names(*args) column_names << options super(*column_names) end protected def selected_column_names(*args) if args.any? args.compact! args.map!(&:to_sym) args else column_names ? column_names.clone : [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.9.0 | lib/datagrid/column_names_attribute.rb |