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

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

Instance Method Summary collapse

Instance Method Details

#changedObject



205
206
207
208
# File 'lib/mobility/plugins/active_model/dirty.rb', line 205

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

#changed?Boolean

Returns:

  • (Boolean)


210
211
212
# File 'lib/mobility/plugins/active_model/dirty.rb', line 210

def changed?
  super || mutations_from_mobility.changed?
end

#changed_attributesObject



192
193
194
# File 'lib/mobility/plugins/active_model/dirty.rb', line 192

def changed_attributes
  super.merge(mutations_from_mobility.changed_attributes)
end

#changesObject



201
202
203
# File 'lib/mobility/plugins/active_model/dirty.rb', line 201

def changes
  super.merge(mutations_from_mobility.changes)
end

#changes_appliedObject



196
197
198
199
# File 'lib/mobility/plugins/active_model/dirty.rb', line 196

def changes_applied
  super
  mutations_from_mobility.finalize_changes
end

#clear_attribute_changes(attr_names) ⇒ Object



223
224
225
226
# File 'lib/mobility/plugins/active_model/dirty.rb', line 223

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

#clear_changes_informationObject



218
219
220
221
# File 'lib/mobility/plugins/active_model/dirty.rb', line 218

def clear_changes_information
  @mutations_from_mobility = nil
  super
end

#previous_changesObject



214
215
216
# File 'lib/mobility/plugins/active_model/dirty.rb', line 214

def previous_changes
  super.merge(mutations_from_mobility.previous_changes)
end