Module: Mobility::Plugins::Dirty

Defined in:
lib/mobility/plugins/dirty.rb

Overview

Note:

Dirty tracking can have unexpected results when combined with fallbacks. A change in the fallback locale value will not mark an attribute falling through to that locale as changed, even though it may look like it has changed. However, when the value for the current locale is changed from nil or blank to a new value, the change will be recorded as a change from that fallback value, rather than from the nil or blank value. The specs are the most reliable source of information on the interaction between dirty tracking and fallbacks.

Dirty tracking for Mobility attributes. See class-specific implementations for details.

Class Method Summary collapse

Class Method Details

.apply(attributes, option) ⇒ Object

Applies dirty plugin to attributes for a given option value.

Parameters:

  • attributes (Attributes)
  • option (Boolean)

    Value of option

Raises:

  • (ArgumentError)

    if model class does not support dirty tracking



30
31
32
33
34
35
# File 'lib/mobility/plugins/dirty.rb', line 30

def apply(attributes, option)
  if option
    FallthroughAccessors.apply(attributes, true)
    include_dirty_module(attributes.backend_class, attributes.model_class, *attributes.names)
  end
end