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