Sha256: 578993ad8f829d2292af0dd7234b52dd6e07bb76f8c83ccba52051851ab86721

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

require 'csv'
require 'active_model'
require 'active_model/exporter'
require 'active_model/exporter/types'
require 'active_model/array_exporter'
require 'active_model/exporter/version'

if defined?(ActionController)
  require 'action_controller/exportation'

  Mime::Type.register('application/vnd.ms-excel', :xls)
  Mime::Type.register('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx)

  ActiveModel::Exporter::TYPES.each do |type|
    ActionController::Renderers.add type do |resource, options|
      method = "to_#{type}".to_sym
      self.content_type ||= "Mime::#{type.upcase}".safe_constantize
      resource.respond_to?(method) ? resource.send(method) : resource
    end
  end

  ActiveSupport.on_load(:action_controller) do
    include ::ActionController::Exportation
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_model_exporters-0.0.4 lib/active_model_exporters.rb