module Crm::Core::Mixins::ChangeLoggable

ChangeLoggable provides access to the change log of a resource. A {ChangeLoggable::Change change log entry} contains the before and after values of all attributes that were changed by an update. It also includes the author (changed_by) and the timestamp (changed_at) of the change. @example

contact
# => Crm::Contact

changes = contact.changes
# => Array<ChangeLoggable::Change>

change = changes.first
# => ChangeLoggable::Change

change.changed_by
# => 'john_smith'

change.changed_at
# => Time

change.details.keys
# => ['email', 'locality']

detail = change.details[:email]
# => ChangeLoggable::Change::Detail

detail.before
# => old@example.com

detail.after
# => new@example.com

@api public

Public Instance Methods

changes(limit: 10) click to toggle source

Returns the most recent changes made to this item. @param limit [Fixnum] the number of changes to return at most.

Maximum: +100+. Default: +10+.

@return [Array<Change>] @api public

# File lib/crm/core/mixins/change_loggable.rb, line 92
def changes(limit: 10)
  RestApi.instance.get("#{path}/changes", {"limit" => limit})['results'].map do |change|
    Change.new(change)
  end
end