class Lograge::LogSubscribers::ActionController
Public Instance Methods
process_action(event)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 4 def process_action(event) process_main_event(event) end
redirect_to(event)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 8 def redirect_to(event) RequestStore.store[:lograge_location] = event.payload[:location] end
unpermitted_parameters(event)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 12 def unpermitted_parameters(event) RequestStore.store[:lograge_unpermitted_params] ||= [] RequestStore.store[:lograge_unpermitted_params].concat(event.payload[:keys]) end
Private Instance Methods
extract_format(payload)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 40 def extract_format(payload) payload[:formats].first end
extract_location()
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 56 def extract_location location = RequestStore.store[:lograge_location] return {} unless location RequestStore.store[:lograge_location] = nil { location: strip_query_string(location) } end
extract_path(payload)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 29 def extract_path(payload) path = payload[:path] strip_query_string(path) end
extract_runtimes(event, payload)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 49 def extract_runtimes(event, payload) data = { duration: event.duration.to_f.round(2) } data[:view] = payload[:view_runtime].to_f.round(2) if payload.key?(:view_runtime) data[:db] = payload[:db_runtime].to_f.round(2) if payload.key?(:db_runtime) data end
extract_unpermitted_params()
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 64 def extract_unpermitted_params unpermitted_params = RequestStore.store[:lograge_unpermitted_params] return {} unless unpermitted_params RequestStore.store[:lograge_unpermitted_params] = nil { unpermitted_params: unpermitted_params } end
initial_data(payload)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 19 def initial_data(payload) { method: payload[:method], path: extract_path(payload), format: extract_format(payload), controller: payload[:controller], action: payload[:action] } end
strip_query_string(path)
click to toggle source
# File lib/lograge/log_subscribers/action_controller.rb, line 34 def strip_query_string(path) index = path.index('?') index ? path[0, index] : path end