Sha256: 47b8c6192a9e90d0c273586b0071e08a96cc3d3b740aa4da6cbb02de9930f088

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

module Approval
  module RequestForm
    class Perform < Base
      private

        def prepare
          ::Approval::Request.transaction do
            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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
approval-0.5.0 app/models/approval/request_form/perform.rb