Sha256: b7a8c993f97728b83b459fe2300ebc01fc1d9e99c3b12539d57e538c8b4d68a8

Contents?: true

Size: 493 Bytes

Versions: 8

Compression:

Stored size: 493 Bytes

Contents

ActiveModel::Exporter::TYPES.each do |type|
  ActionController::Renderers.add type do |resource, options|
    method = "to_#{type}".to_sym

    if resource.respond_to?(method)
      encode = options[:encode] || 'iso-8859-1'
      mtype  = "Mime::#{type.upcase}".safe_constantize
      file   = resource.send(method).encode(encode)

      default_options = {type: mtype, disposition: 'attachment'}
      send_data(file, default_options.merge(options))
    else
      resource
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_model_exporters-0.4.1 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.4.0 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.3.2 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.3.1 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.3.0 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.2.0 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.1.0 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.0.5 lib/action_controller/exportation/renderers.rb