lib/active_admin/csv_builder.rb in activeadmin-0.6.0 vs lib/active_admin/csv_builder.rb in activeadmin-0.6.1

- old
+ new

@@ -5,11 +5,11 @@ # # csv_builder = CSVBuilder.new # csv_builder.column :id # csv_builder.column("Name") { |resource| resource.full_name } # - # csv_builder = CSVBuilder.new :separator => ";" + # csv_builder = CSVBuilder.new :col_sep => ";" # csv_builder.column :id # # class CSVBuilder @@ -23,26 +23,24 @@ csv_builder.column(content_column.name.to_sym) end end end - attr_reader :columns, :column_separator, :options + attr_reader :columns, :options def initialize(options={}, &block) - @columns = [] - @column_separator = options.delete(:separator) - @options = options.delete(:options) + @columns, @options = [], options instance_eval &block if block_given? end # Add a column def column(name, &block) @columns << Column.new(name, block) end class Column attr_reader :name, :data - + def initialize(name, block = nil) @name = name.is_a?(Symbol) ? name.to_s.titleize : name @data = block || name.to_sym end end