Sha256: 037b858d2d7f723672ddcff15a5a56f54e1f67cd7dc416adbc6b24d00bd1d856

Contents?: true

Size: 618 Bytes

Versions: 4

Compression:

Stored size: 618 Bytes

Contents

module Approval
  module RespondForm
    class ApproveWithExecute < Base
      validate :ensure_user_cannot_respond_to_my_request

      private

        def prepare
          instrument "approve_with_execute" do |payload|
            ::Approval::Request.transaction do
              request.lock!
              request.assign_attributes(state: :approved, approved_at: Time.current, respond_user_id: user.id)
              payload[:comment] = request.comments.new(user_id: user.id, content: reason)
              request.execute
              yield(request)
            end
          end
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
approval-0.7.1 app/models/approval/respond_form/approve_with_execute.rb
approval-0.7.0 app/models/approval/respond_form/approve_with_execute.rb
approval-0.6.1 app/models/approval/respond_form/approve_with_execute.rb
approval-0.6.0 app/models/approval/respond_form/approve_with_execute.rb