Sha256: fcf58e249bd031838dbeb3ef441e0e967ddef05a4d3ab90da64cfb85b59c84e4
Contents?: true
Size: 835 Bytes
Versions: 2
Compression:
Stored size: 835 Bytes
Contents
module ActionController module Exportation extend ActiveSupport::Concern included do class_attribute :_exportation_scope self._exportation_scope = :current_user end module ClassMethods def exportation_scope(scope) self._exportation_scope = scope end end def _render_option_csv(resource, options) exporter = build_exporter(resource, options) exporter ? super(exporter, options) : super end private def exportation_scope scope = self.class._exportation_scope send(scope) if scope && respond_to?(scope, true) end def build_exporter(resource, options) if exporter = ActiveModel::Exporter.exporter_for(resource) options[:scope] ||= exportation_scope exporter.new(resource, options) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_model_exporters-0.0.3 | lib/action_controller/exportation.rb |
active_model_exporters-0.0.2 | lib/action_controller/exportation.rb |