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) ⇒ Headers

Returns a new instance of Headers.



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

def initialize(env)
  @env = env
end

Instance Attribute Details

#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



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

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

#to_aObject



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

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

#to_sObject



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

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