Sha256: 20e7de4fc058485853edeeeae3af3de0aad420c7ad0b96bbcbe22c7ce4e3928e

Contents?: true

Size: 427 Bytes

Versions: 4

Compression:

Stored size: 427 Bytes

Contents

module RenderAsCSV
  def self.included(base)
    base.alias_method_chain :render, :csv
  end

  def render_with_csv(options = nil, extra_options = {}, &block)
    return render_without_csv(options, extra_options, &block) unless options.is_a?(Hash) and options[:csv]
    data = options.delete(:csv)
    style = options.delete(:style) || :default
    send_data Array(data).to_comma(style), options.merge(:type => :csv)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
comma-0.3.2 lib/comma/render_as_csv.rb
comma-0.3.1 lib/comma/renderascsv.rb
liangzan-comma-0.3.1 lib/comma/render_as_csv.rb
comma-0.3.0 lib/comma/RenderAsCSV.rb