Sha256: f7888d7320cb50250b3be2382a7fccc1b7e4bdc77aceb4b821dde7da9120b140

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

# frozen_string_literal: true

module Logux
  class Stream
    attr_reader :stream

    delegate :close, to: :stream

    def initialize(stream)
      @stream = stream
    end

    def write(payload)
      processed_payload = process(payload)
      Logux.logger.debug("Write to Logux response: #{processed_payload}")
      stream.write(processed_payload)
    end

    private

    def process(payload)
      payload.is_a?(::String) ? payload : payload.to_json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logux_rails-0.1.0 lib/logux/stream.rb