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

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

Instance Method Summary collapse

Instance Method Details

#changedObject


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

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

#changed?Boolean

Returns:

  • (Boolean)

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

def changed?
  super || mutations_from_mobility.changed?
end

#changed_attributesObject


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

def changed_attributes
  super.merge(mutations_from_mobility.changed_attributes)
end

#changesObject


187
188
189
# File 'lib/mobility/plugins/active_model/dirty.rb', line 187

def changes
  super.merge(mutations_from_mobility.changes)
end

#changes_appliedObject


182
183
184
185
# File 'lib/mobility/plugins/active_model/dirty.rb', line 182

def changes_applied
  super
  mutations_from_mobility.finalize_changes
end

#clear_attribute_changes(attr_names) ⇒ Object


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

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

#clear_changes_informationObject


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

def clear_changes_information
  @mutations_from_mobility = nil
  super
end

#previous_changesObject


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

def previous_changes
  super.merge(mutations_from_mobility.previous_changes)
end