class TraceHeader::Result
Attributes
target_app[R]
Public Class Methods
new(target_app, outputs)
click to toggle source
# File lib/trace_header/result.rb, line 5 def initialize(target_app, outputs) @target_app = target_app @target_hash = outputs.find { |output| output[:middleware].eql?(target_app.class) } @inner_hash = outputs[outputs.index(@target_hash) + 1] end
Public Instance Methods
changed_headers()
click to toggle source
# File lib/trace_header/result.rb, line 15 def changed_headers headers(changed_fields) end
new_headers()
click to toggle source
# File lib/trace_header/result.rb, line 11 def new_headers headers(new_fields) end
Private Instance Methods
changed_fields()
click to toggle source
# File lib/trace_header/result.rb, line 29 def changed_fields common_fields.select { |field| target_header[field] != prev_header[field] } end
common_fields()
click to toggle source
# File lib/trace_header/result.rb, line 21 def common_fields target_header.keys & prev_header.keys end
headers(fields)
click to toggle source
# File lib/trace_header/result.rb, line 45 def headers(fields) fields.map { |field| { field => target_header[field].to_s } } end
new_fields()
click to toggle source
# File lib/trace_header/result.rb, line 25 def new_fields target_header.keys - common_fields end
prev_header()
click to toggle source
# File lib/trace_header/result.rb, line 37 def prev_header @prev_header ||= rack_app(@inner_hash)[1] end
rack_app(hash)
click to toggle source
# File lib/trace_header/result.rb, line 41 def rack_app(hash) hash[:app].call(hash[:env]) end
target_header()
click to toggle source
# File lib/trace_header/result.rb, line 33 def target_header @target_header ||= rack_app(@target_hash)[1] end