module WcMonitor::ControllerMethods
Public Instance Methods
logger_wc_monitoring_result()
click to toggle source
# File lib/wc_monitor/controller.rb, line 3 def logger_wc_monitoring_result found = [] WcMonitor.registry.each do |record| accessed = if record.respond_to?(:accessed_fields) record.accessed_fields else # for Rails < 5.1 attributes = record.instance_variable_get(:@attributes) lazy_attributes = attributes.instance_variable_get(:@attributes) lazy_attributes.select{|_, v| v.instance_variable_get(:@value).present? }.keys end unused = (record.attributes.keys - accessed) next if unused.empty? primary_key = record.class.primary_key found << [record.class.name, primary_key, unused] end if found.any? WcMonitor.logger.info("#{controller_name}##{action_name}") found.each { |result| WcMonitor.logger.info("#{result}") } WcMonitor.logger.info("\n") end ensure WcMonitor.clear_registry end