Sha256: fe20ce58376509b9c6b17387ebe547863af642a5aa9b11bc6918abf67eb6058e

Contents?: true

Size: 707 Bytes

Versions: 18

Compression:

Stored size: 707 Bytes

Contents

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)
        Thread.current[:current_exhibit] = exhibit
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.4.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.3.3 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.3.2 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.3.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.3.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.2.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.2.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.1.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.2 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.1 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0.rc6 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0.rc5 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0.rc4 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0.rc3 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0.rc2 app/models/concerns/spotlight/custom_translation_extension.rb
blacklight-spotlight-2.0.0.rc1 app/models/concerns/spotlight/custom_translation_extension.rb