module Mobility
  module Sequel
    class ColumnChanges < Module
      def initialize(attributes)
        @attributes = attributes

        define_method :mobility_set do |attribute, value, locale: Mobility.locale|
          if attributes.include?(attribute)
            column = :"#{attribute}_#{locale}"
            @changed_columns << column if !changed_columns.include?(column) && (mobility_get(attribute) != value)
          end
          super(attribute, value, locale: locale)
        end
        private :mobility_set
      end
    end
  end
end

module Mobility
  module Sequel
    class ColumnChanges < Module
      def initialize(attributes)
        @attributes = attributes

        define_method :mobility_set do |attribute, value, locale: Mobility.locale|
          if attributes.include?(attribute)
            column = attribute.to_sym
            column_with_locale = :"#{attribute}_#{locale}"
            if mobility_get(attribute) != value
              @changed_columns << column_with_locale if !changed_columns.include?(column_with_locale)
              @changed_columns << column             if !changed_columns.include?(column)
            end
          end
          super(attribute, value, locale: locale)
        end
        private :mobility_set
      end
    end
  end
end

Mark both attr and attr_<locale> in column changes module
Mark both attr and attr_<locale> in column changes module

If we do not add the attribute name itself to column_changes, then
backends that actually change the a column with the name of the
attribute will not get the column updated, since Sequel checks to see if
the changed column is actually a real column.

So instead, we should mark *both* e.g. `title` *and* `title_en`.
