Module: Crm::Core::Mixins::ChangeLoggable

Included in:
Account, Activity, Crm::Collection, Crm::Contact, Event, EventContact, Mailing, TemplateSet, Type
Defined in:
lib/crm/core/mixins/change_loggable.rb

Overview

ChangeLoggable provides access to the change log of a resource. A 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.

Examples:

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
# => [email protected]

detail.after
# => [email protected]

Defined Under Namespace

Classes: Change

Instance Method Summary collapse

Instance Method Details

#changes(limit: 10) ⇒ Array<Change>

Returns the most recent changes made to this item.

Parameters:

  • limit (Fixnum) (defaults to: 10)

    the number of changes to return at most. Maximum: 100. Default: 10.

Returns:



92
93
94
95
96
# 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