Class: RailsRiemannMiddleware::Headers

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, custom_headers = []) ⇒ Headers

Returns a new instance of Headers.



7
8
9
10
# File 'lib/rails_riemann_middleware/headers.rb', line 7

def initialize(env, custom_headers=[])
  @env = env
  @custom_headers = custom_headers
end

Instance Attribute Details

#custom_headersObject (readonly)

Returns the value of attribute custom_headers.



5
6
7
# File 'lib/rails_riemann_middleware/headers.rb', line 5

def custom_headers
  @custom_headers
end

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/rails_riemann_middleware/headers.rb', line 5

def env
  @env
end

Instance Method Details

#keysObject



12
13
14
# File 'lib/rails_riemann_middleware/headers.rb', line 12

def keys
  %w{REQUEST_METHOD REQUEST_URI PATH_INFO HTTP_X_REAL_IP HTTP_USER_AGENT HTTP_REFERER} + custom_headers
end

#to_aObject



16
17
18
# File 'lib/rails_riemann_middleware/headers.rb', line 16

def to_a
  keys.map { |h| " #{h.downcase}: #{env.fetch(h, "N/A")}" }
end

#to_sObject



20
21
22
# File 'lib/rails_riemann_middleware/headers.rb', line 20

def to_s
  to_a.join("\n")
end