Sha256: 424c955e53eb5c097528b937d42ee1f4cc2f436c67801fae67d53df6116a1046

Contents?: true

Size: 622 Bytes

Versions: 1

Compression:

Stored size: 622 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); end

        def to_h
          {
            statusCode: status,
            headers: headers,
            body: 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/.rbnext/3.0/active_function/functions/response.rb