Class: Atatus::Transport::Headers Private

Inherits:
Object
  • Object
show all
Defined in:
lib/atatus/transport/headers.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

HEADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  'Content-Type' => 'application/x-ndjson',
  'Transfer-Encoding' => 'chunked'
}.freeze
GZIP_HEADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

HEADERS.merge(
  'Content-Encoding' => 'gzip'
).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, initial: {}) ⇒ Headers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Headers.



32
33
34
35
# File 'lib/atatus/transport/headers.rb', line 32

def initialize(config, initial: {})
  @config = config
  @hash = build!(initial)
end

Instance Attribute Details

#hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/atatus/transport/headers.rb', line 37

def hash
  @hash
end

Instance Method Details

#[](key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/atatus/transport/headers.rb', line 39

def [](key)
  @hash[key]
end

#[]=(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
# File 'lib/atatus/transport/headers.rb', line 43

def []=(key, value)
  @hash[key] = value
end

#chunkedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
63
64
# File 'lib/atatus/transport/headers.rb', line 60

def chunked
  merge(
    @config.http_compression? ? GZIP_HEADERS : HEADERS
  )
end

#merge(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/atatus/transport/headers.rb', line 47

def merge(other)
  self.class.new(@config, initial: @hash.merge(other))
end

#merge!(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
54
# File 'lib/atatus/transport/headers.rb', line 51

def merge!(other)
  @hash.merge!(other)
  self
end

#to_hObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
# File 'lib/atatus/transport/headers.rb', line 56

def to_h
  @hash
end