Sha256: cf1e8d411b55f2048e7b5e39fd4104690f80c3cedbc21e78bf9fbede481956f0

Contents?: true

Size: 513 Bytes

Versions: 2

Compression:

Stored size: 513 Bytes

Contents

module Approval
  module RespondForm
    class ApproveWithExecute < Base
      validate :ensure_user_cannot_respond_to_my_request

      private

        def prepare
          ::Approval::Request.transaction do
            request.lock!
            request.assign_attributes(state: :approved, approved_at: Time.current, respond_user_id: user.id)
            request.comments.new(user_id: user.id, content: reason)
            request.execute
            yield(request)
          end
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
approval-0.5.0 app/models/approval/respond_form/approve_with_execute.rb
approval-0.4.0 app/models/approval/respond_form/approve_with_execute.rb