Sha256: 4879f712145ba941822d00cf2df8cefbb138d142ab4bf0cab7c3466b0bd2ca20

Contents?: true

Size: 860 Bytes

Versions: 2

Compression:

Stored size: 860 Bytes

Contents

module Praxis
  module Responses
    class MultipartOk < Ok

      def initialize(status:self.class.status, headers:{}, body:'')
        @name    = response_name
        @status  = status
        @headers = headers
        @body    = body
      end

      def handle
        case @body
        when Praxis::Types::MultipartArray
          if @headers['Content-Type'].nil?
            @headers['Content-Type'] = @body.content_type
          end
        end
      end


      def encode!(handlers:)
        case @body
        when Praxis::Types::MultipartArray
          @body = @body.dump
        else
          super
        end
      end

      def finish(application:)
        format!(config: application.config)
        encode!(handlers: application.handlers)

        @body = Array(@body)

        [@status, @headers, @body]
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
praxis-0.22.pre.2 lib/praxis/responses/multipart_ok.rb
praxis-0.22.pre.1 lib/praxis/responses/multipart_ok.rb