Sha256: 5e84796d53f3db6e3efcef6058e6cc9b06c3a44fc1c4ebdc8ef0e1805822fc8d

Contents?: true

Size: 471 Bytes

Versions: 5

Compression:

Stored size: 471 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.to_sym]
      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

5 entries across 5 versions & 1 rubygems

Version Path
active_model_exporters-0.7.0 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.6.0 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.5.2 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.5.1 lib/action_controller/exportation/renderers.rb
active_model_exporters-0.5.0 lib/action_controller/exportation/renderers.rb