Sha256: 5814afc679a1d9510afd10e9588d2a81c3e68121fd12a222675065c89f30dc01
Contents?: true
Size: 980 Bytes
Versions: 8
Compression:
Stored size: 980 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 ActiveModel::Exporter::TYPES.each do |type| [:_render_option_, :_render_with_renderer_].each do |prefix| define_method "#{prefix}#{type}" do |resource, options| exporter = build_exporter(resource, options) exporter ? super(exporter, options) : super end end 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::ArrayExporter options[:scope] ||= exportation_scope exporter.new(resource, options) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems