Module: Mobility::Backend::Sequel::Dirty
- Defined in:
- lib/mobility/backend/sequel/dirty.rb
Overview
Dirty tracking for Sequel models which use the Sequel::Plugins::Dirty
plugin.
Defined Under Namespace
Modules: ClassMethods
Backend Accessors collapse
-
#write(locale, value, **options) ⇒ Object
Updated value.
Class Method Summary collapse
Class Method Details
.included(backend_class) ⇒ Object
26 27 28 |
# File 'lib/mobility/backend/sequel/dirty.rb', line 26 def self.included(backend_class) backend_class.extend(ClassMethods) end |
Instance Method Details
#write(locale, value, **options) ⇒ Object
Returns Updated value.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mobility/backend/sequel/dirty.rb', line 13 def write(locale, value, **) locale_accessor = "#{attribute}_#{locale}".to_sym if model.column_changes.has_key?(locale_accessor) && model.initial_values[locale_accessor] == value super [model.changed_columns, model.initial_values].each { |h| h.delete(locale_accessor) } else model.will_change_column("#{attribute}_#{locale}".to_sym) super end end |