Sha256: ed20f2e3cda3abd6e9fb0a0b7407aa6df550a80faa7aa3ac465ef7dc61c9c9c5

Contents?: true

Size: 502 Bytes

Versions: 5

Compression:

Stored size: 502 Bytes

Contents

module Approval
  module RespondForm
    class Approve < 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: user)
            request.comments.new(user: user, content: reason)
            request.items.each(&:apply)
            yield(request)
          end
        end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
approval-0.3.4 lib/approval/models/approval/respond_form/approve.rb
approval-0.3.3 lib/approval/models/approval/respond_form/approve.rb
approval-0.3.2 lib/approval/models/approval/respond_form/approve.rb
approval-0.3.1 lib/approval/models/approval/respond_form/approve.rb
approval-0.3.0 lib/approval/models/approval/respond_form/approve.rb