Sha256: eb77772399949bf8ce61ef438c7bede98645ec86782cced46722e7fbfa3aaaac

Contents?: true

Size: 741 Bytes

Versions: 4

Compression:

Stored size: 741 Bytes

Contents

module Approval
  module RequestForm
    class Perform < Base
      private

        def prepare
          instrument "request" do |payload|
            ::Approval::Request.transaction do
              payload[:comment] = request.comments.new(user_id: user.id, content: reason)
              Array(records).each do |record|
                request.items.new(
                  event: "perform",
                  resource_type: record.class.to_s,
                  params: extract_params_from(record),
                )
              end
              yield(request)
            end
          end
        end

        def extract_params_from(record)
          record.try(:attributes) || record.try(:to_h) || {}
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
approval-0.7.1 app/models/approval/request_form/perform.rb
approval-0.7.0 app/models/approval/request_form/perform.rb
approval-0.6.1 app/models/approval/request_form/perform.rb
approval-0.6.0 app/models/approval/request_form/perform.rb