Module: Workarea::Configuration::LocalizedActiveFields

Extended by:
LocalizedActiveFields
Included in:
LocalizedActiveFields
Defined in:
lib/workarea/configuration/localized_active_fields.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#loadObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/workarea/configuration/localized_active_fields.rb', line 13

def load
  return if Workarea.config.localized_active_fields

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