class Rage::Configuration::LogContext
def <<(block_or_hash)
- Note: - Exceptions from dynamic context callables will cause the entire request to fail. Make sure to handle exceptions inside the callable if necessary.
Parameters:
-
callable(#call) -- a callable object that returns a hash representing the log context or nil -
hash(Hash) -- a hash representing the log context
Overloads:
-
<<(callable) -
<<(hash)
def <<(block_or_hash) validate_input!(block_or_hash) @objects << block_or_hash @objects.tap(&:flatten!).tap(&:uniq!) self end
def delete(block_or_hash)
-
block_or_hash(Hash, #call) -- the context object to remove
def delete(block_or_hash) @objects.delete(block_or_hash) end
def initialize
- Private: -
def initialize @objects = [] end
def objects
- Private: -
def objects @objects.dup end
def validate_input!(obj)
def validate_input!(obj) if obj.is_a?(Array) obj.each { |item| validate_input!(item) } elsif !obj.is_a?(Hash) && !obj.respond_to?(:call) raise ArgumentError, "custom log context has to be a hash, an array of hashes, or respond to `#call`" end end