Sha256: 5626d2e3c1b3dde081275b6f94601be0da4697edf0f64766d4838c83fa858ef0

Contents?: true

Size: 665 Bytes

Versions: 4

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

require 'action_view'
require 'stringio'

module ActionView
  class Template
    module Handlers
      class CSVRbBuilder

        def default_format
          Mime[:csv]
        end

        def call(template)
          builder = StringIO.new
          builder << "require 'csv';"
          builder << "require 'csv_rb/plain_builder';"
          builder << "csv ||= CSVRb::PlainBuilder.new;"
          builder << template.source
          builder << ";csv = csv.to_str if csv.is_a?(CSVRb::PlainBuilder); csv;"
          builder.string
        end

        def handles_encoding?
          true
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
csv_rb-5.2.3 lib/csv_rb/template_handler.rb
csv_rb-5.2.2 lib/csv_rb/template_handler.rb
csv_rb-5.2.1 lib/csv_rb/template_handler.rb
csv_rb-0.5.2 lib/csv_rb/template_handler.rb