Class: Gallus::Payload

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/gallus/payload.rb

Overview

Internal: To improve performance, context can provide values wrapped in lambdas. Those will be executed at the time of writing log. Getting the values from lambdas is the job of this simple payload class.

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Payload

Returns a new instance of Payload.



13
14
15
16
17
18
# File 'lib/gallus/payload.rb', line 13

def initialize(payload)
  @h = payload.inject({}) do |res,(k,v)|
    res[k.to_sym] = v.is_a?(Proc) ? v.call : v
    res
  end
end

Instance Method Details

#inspectObject



24
25
26
# File 'lib/gallus/payload.rb', line 24

def inspect
  @h.map { |k,v| "#{k}=#{v.inspect}" }.join(" ")
end

#to_hObject



20
21
22
# File 'lib/gallus/payload.rb', line 20

def to_h
  @h
end