Sha256: 39328196992351e922d0171dd0e654b78afee2273b1fc704416415ddfdcecf8c

Contents?: true

Size: 815 Bytes

Versions: 70

Compression:

Stored size: 815 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Module that extends I18n::Backend::ActiveRecord::Translation to provide
  # additional Spotlight behavior, such as exhibit specific Translations
  module CustomTranslationExtension
    extend ActiveSupport::Concern

    included do
      default_scope { where(exhibit: current_exhibit) }
      belongs_to :exhibit, class_name: 'Spotlight::Exhibit', inverse_of: :translations

      before_validation do
        mark_for_destruction if value.blank?
      end
    end

    class_methods do
      def current_exhibit
        Thread.current[:current_exhibit]
      end

      def current_exhibit=(exhibit)
        I18n.backend.reload! if Thread.current[:current_exhibit] != exhibit

        Thread.current[:current_exhibit] = exhibit
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
blacklight-spotlight-4.3.6 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.3.5 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.3.4 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.3.3 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.3.2 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.3.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.3.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.2.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.1.2 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.1.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.1.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.0.3 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.0.2 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.0.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-4.0.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-3.6.0.beta10 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-3.6.0.beta9 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-3.6.0.beta8 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-3.5.0.4 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-3.6.0.beta7 app/models/concerns/spotlight/custom_translation_extension.rb