Sha256: 8e948388db5f5be705de3d16b546844b9286b4f3a16e7e7bd3d0b3a771bc373a

Contents?: true

Size: 831 Bytes

Versions: 3

Compression:

Stored size: 831 Bytes

Contents

module Workarea
  module Configuration
    # This gets around a configuration problem where we want field definition
    # to depend on configuration, but fields are defined before configuration.
    # So this redefines the active field if we're doing localized active fields
    # (which will become the default in v3.4).
    #
    # TODO remove this in v4.0
    #
    module LocalizedActiveFields
      extend self

      def load
        return if Workarea.config.localized_active_fields

        ::Mongoid.models.each do |klass|
          if klass < Releasable && klass.localized_fields['active'].present?
            klass.localized_fields.delete('active')
            klass.field(:active, type: Boolean, default: true, localize: false)
            klass.index(active: 1)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-core-3.5.27 lib/workarea/configuration/localized_active_fields.rb
workarea-core-3.5.26 lib/workarea/configuration/localized_active_fields.rb
workarea-core-3.5.25 lib/workarea/configuration/localized_active_fields.rb