module TinyDyno::Changeable
Defines behaviour for dirty tracking.
@since 4.0.0
Public Instance Methods
changes()
click to toggle source
Get all the changes for the document.
@example Get all the changes.
model.changes
@return [ Hash<String, Array<Object, Object> ] The changes.
@since 2.4.0
# File lib/tiny_dyno/changeable.rb, line 42 def changes _changes = {} changed.each do |attr| next if attr.nil? change = attribute_change(attr) _changes[attr] = change end _changes end
Private Instance Methods
attribute_change(attr)
click to toggle source
Get the old and new value for the provided attribute.
@example Get the attribute change.
model.attribute_change("name")
@param [ String ] attr The name of the attribute.
@return [ Array<Object> ] The old and new values.
@since 2.1.0
# File lib/tiny_dyno/changeable.rb, line 64 def attribute_change(attr) attr = database_field_name(attr) [changed_attributes[attr], attributes[attr]] if (attribute_changed?(attr) && !attr.nil?) end