Module: ActsAsApprovable::Model::UpdateInstanceMethods

Defined in:
lib/acts_as_approvable/model/update_instance_methods.rb

Overview

Instance methods that apply to the :update event specifically.

Instance Method Summary collapse

Instance Method Details

#approvable_fieldsObject

Returns a list of fields that require approval.



36
37
38
# File 'lib/acts_as_approvable/model/update_instance_methods.rb', line 36

def approvable_fields
  self.class.approvable_fields
end

#changed_notably?Boolean

Returns true if any notable (eg. not ignored) fields have been changed.

Returns:

  • (Boolean)


21
22
23
# File 'lib/acts_as_approvable/model/update_instance_methods.rb', line 21

def changed_notably?
  notably_changed.any?
end

#notably_changedArray

Returns an array of any notable (eg. not ignored) fields that have not been changed.

Returns:

  • (Array)

    a list of changed fields.



30
31
32
# File 'lib/acts_as_approvable/model/update_instance_methods.rb', line 30

def notably_changed
  approvable_fields.select { |field| changed.include?(field) }
end

#pending_changes?Boolean

Returns true if the record has any ‘#update_approvals` that are pending approval.

Returns:

  • (Boolean)


15
16
17
# File 'lib/acts_as_approvable/model/update_instance_methods.rb', line 15

def pending_changes?
  !update_approvals(false).empty?
end

#update_approvals(all = true) ⇒ Object

Retrieve all approval records for ‘:update` events.



8
9
10
# File 'lib/acts_as_approvable/model/update_instance_methods.rb', line 8

def update_approvals(all = true)
  all ? approvals.find_all_by_event('update') : approvals.find_all_by_event_and_state('update', 0)
end