Module: Mobility::Plugins::ActiveModel::Dirty::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#changedObject


159
160
161
162
# File 'lib/mobility/plugins/active_model/dirty.rb', line 159

def changed
  # uniq is required for Rails < 6.0
  (super + mutations_from_mobility.changed).uniq
end

#changed?Boolean

Returns:

  • (Boolean)

164
165
166
# File 'lib/mobility/plugins/active_model/dirty.rb', line 164

def changed?
  super || mutations_from_mobility.changed?
end

#changed_attributesObject


146
147
148
# File 'lib/mobility/plugins/active_model/dirty.rb', line 146

def changed_attributes
  super.merge(mutations_from_mobility.changed_attributes)
end

#changesObject


155
156
157
# File 'lib/mobility/plugins/active_model/dirty.rb', line 155

def changes
  super.merge(mutations_from_mobility.changes)
end

#changes_appliedObject


150
151
152
153
# File 'lib/mobility/plugins/active_model/dirty.rb', line 150

def changes_applied
  super
  mutations_from_mobility.finalize_changes
end

#clear_attribute_changes(attr_names) ⇒ Object


177
178
179
180
# File 'lib/mobility/plugins/active_model/dirty.rb', line 177

def clear_attribute_changes(attr_names)
  attr_names.each { |attr_name| mutations_from_mobility.restore_attribute!(attr_name) }
  super
end

#clear_changes_informationObject


172
173
174
175
# File 'lib/mobility/plugins/active_model/dirty.rb', line 172

def clear_changes_information
  @mutations_from_mobility = nil
  super
end

#previous_changesObject


168
169
170
# File 'lib/mobility/plugins/active_model/dirty.rb', line 168

def previous_changes
  super.merge(mutations_from_mobility.previous_changes)
end