Sha256: 9a3e4c83913d056e162d8319436946f77ffad5fc12890dda713524e5368fd16d

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

module ActiveFunction
  module Functions
    module Response
      ActiveFunction.register_plugin :response, self

      class Response < Struct.new(:status, :headers, :body, :committed)
        def initialize(status: 200, headers: {}, body: nil, committed: false) = super(status, headers, body, committed)

        def to_h
          {
            statusCode: status,
            headers:,
            body:
          }
        end

        def commit!
          self.committed = true
        end

        alias_method :committed?, :committed
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activefunction-0.4.0 lib/active_function/functions/response.rb