module Rack::ActionLogger::Container
Constants
- EXPORT_KEYS
- THREAD_KEY
Public Class Methods
add_append_log(hash, tag=nil)
click to toggle source
# File lib/rack/action_logger/container.rb, line 23 def add_append_log(hash, tag=nil) return unless is_valid_hash hash return unless is_valid_tag tag hash[:tag] = tag append_logs.push(hash) end
append_logs()
click to toggle source
# File lib/rack/action_logger/container.rb, line 30 def append_logs store[:rack_action_logger_append_logs] ||= [] end
attributes()
click to toggle source
# File lib/rack/action_logger/container.rb, line 39 def attributes store[:rack_action_logger_attributes] ||= {} end
clear()
click to toggle source
# File lib/rack/action_logger/container.rb, line 11 def clear Thread.current[THREAD_KEY] = nil end
export()
click to toggle source
# File lib/rack/action_logger/container.rb, line 54 def export EXPORT_KEYS.inject({}) do |result, key| result[key] = store[key] if store[key] result end end
import(hash)
click to toggle source
# File lib/rack/action_logger/container.rb, line 61 def import(hash) hash.symbolize_keys.each do |key, value| next unless EXPORT_KEYS.include? key store[key] = value end end
is_emit_started()
click to toggle source
# File lib/rack/action_logger/container.rb, line 19 def is_emit_started store[:rack_action_logger_emit_started] ||= false end
is_emit_started=(value)
click to toggle source
# File lib/rack/action_logger/container.rb, line 15 def is_emit_started=(value) store[:rack_action_logger_emit_started] = value end
merge_attributes(attributes)
click to toggle source
# File lib/rack/action_logger/container.rb, line 34 def merge_attributes(attributes) return unless is_valid_hash attributes self.attributes = self.attributes.merge! attributes end
request_log()
click to toggle source
# File lib/rack/action_logger/container.rb, line 50 def request_log store[:rack_action_logger_request_log] ||= {} end
set_request_log(hash, tag=nil)
click to toggle source
# File lib/rack/action_logger/container.rb, line 43 def set_request_log(hash, tag=nil) return unless is_valid_hash hash return unless is_valid_tag tag hash[:tag] = tag self.request_log = hash end
Private Class Methods
attributes=(value)
click to toggle source
# File lib/rack/action_logger/container.rb, line 92 def attributes=(value) store[:rack_action_logger_attributes] = value end
is_valid_hash(hash)
click to toggle source
# File lib/rack/action_logger/container.rb, line 74 def is_valid_hash(hash) if hash.is_a? Hash true else Rack::ActionLogger.logger.error("invalid hash: #{hash}") false end end
is_valid_tag(tag)
click to toggle source
# File lib/rack/action_logger/container.rb, line 83 def is_valid_tag(tag) if tag.nil? || tag.is_a?(String) true else Rack::ActionLogger.logger.error("invalid tag: #{tag}") false end end
request_log=(value)
click to toggle source
# File lib/rack/action_logger/container.rb, line 96 def request_log=(value) store[:rack_action_logger_request_log] = value end
store()
click to toggle source
# File lib/rack/action_logger/container.rb, line 70 def store Thread.current[THREAD_KEY] ||= {} end