public
Description: simple identity map for active record. eager loading associations FTL
Clone URL: git://github.com/technoweenie/active_record_context.git
Click here to lend your support to: active_record_context and make a donation at www.pledgie.com !
add logging

git-svn-id: 
http://svn.techno-weenie.net/projects/plugins/active_record_context@2514 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Nov 26 00:21:19 -0800 2006
commit  dd59f8aa8ca5573285624e85641d938f7dfdc287
tree    5d053ba72e4605eff70ac10bf1cd78fab05ad36e
parent  239e3da70a266de8079c54a29020bc8e1092026f
0
...
15
16
17
18
19
 
 
 
20
...
15
16
17
 
18
19
20
21
22
0
@@ -15,4 +15,6 @@ It only uses the context when it's activated. To activate, you can set a contro
0
     ActiveRecord::Base.with_context do
0
       yield
0
     end
0
- end
0
\ No newline at end of file
0
+ end
0
+
0
+Set Technoweenie::ActiveRecordContext.log_context_activity = true to turn on debug logging.
0
\ No newline at end of file
...
7
8
9
 
10
11
12
...
17
18
19
 
20
21
22
...
26
27
28
 
29
30
31
...
7
8
9
10
11
12
13
...
18
19
20
21
22
23
24
...
28
29
30
31
32
33
34
0
@@ -7,6 +7,7 @@ module Technoweenie
0
       end
0
     end
0
     
0
+ mattr_accessor :log_context_activity
0
     mattr_reader :context_cache
0
 
0
     def find_every_with_context(options)
0
@@ -17,6 +18,7 @@ module Technoweenie
0
     
0
     def find_one_with_context(id, options)
0
       cached = options[:conditions].nil? && find_in_context(id)
0
+ logger.debug "[Context] Found #{name} ##{id}}" if log_context_activity && cached
0
       cached ? cached : find_one_without_context(id, options)
0
     end
0
 
0
@@ -26,6 +28,7 @@ module Technoweenie
0
     
0
     def store_in_context(records)
0
       return if context_cache.nil?
0
+ logger.debug "[Context] Storing #{name} records: #{records.collect(&:id).to_sentence}" if log_context_activity
0
       records.inject(context_cache[self] ||= {}) do |memo, record|
0
         memo.update record.id => record
0
       end

Comments

    No one has commented yet.