lib/mobility/sequel/column_changes.rb in mobility-0.3.6 vs lib/mobility/sequel/column_changes.rb in mobility-0.4.0
- old
+ new
@@ -6,20 +6,17 @@
setter method is called.
=end
class ColumnChanges < Module
# @param [Array<String>] attributes Backend attributes
- def initialize(attributes)
- @attributes = attributes
-
+ def initialize(*attributes)
attributes.each do |attribute|
define_method "#{attribute}=".freeze do |value, **options|
if !options[:super] && send(attribute) != value
locale = options[:locale] || Mobility.locale
column = attribute.to_sym
column_with_locale = :"#{attribute}_#{Mobility.normalize_locale(locale)}"
- @changed_columns << column_with_locale if !changed_columns.include?(column_with_locale)
- @changed_columns << column if !changed_columns.include?(column)
+ @changed_columns = changed_columns | [column, column_with_locale]
end
super(value, **options)
end
end
end