app/models/approval/execute_form.rb in approval-0.5.0 vs app/models/approval/execute_form.rb in approval-0.6.0
- old
+ new
@@ -1,8 +1,9 @@
module Approval
class ExecuteForm
include ::ActiveModel::Model
+ include ::Approval::FormNotifiable
attr_accessor :user, :reason, :request
def initialize(user:, reason:, request:)
@user = user
@@ -30,14 +31,16 @@
end
private
def execute
- ::Approval::Request.transaction do
- request.lock!
- request.comments.new(user_id: user.id, content: reason) if reason
- request.execute
- yield(request)
+ instrument "execute" do |payload|
+ ::Approval::Request.transaction do
+ request.lock!
+ payload[:comment] = request.comments.new(user_id: user.id, content: reason) if reason
+ request.execute
+ yield(request)
+ end
end
end
def ensure_request_is_approved
return unless request