3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# 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
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
|