@@ -229,6 +229,26 @@ def initialize(db_cache, acting_user, klass, preloaded_records)
229229 @db_cache . add_item_to_cache self
230230 end
231231
232+ def to_s
233+ acting_user_string =
234+ if acting_user
235+ " - with acting user: <#{ acting_user . class . name } id: #{ acting_user . id } >"
236+ else
237+ ' - with no acting user'
238+ end
239+ vector . collect do |e |
240+ if e . is_a? String
241+ e
242+ elsif e . is_a? Array
243+ e . length > 1 ? "#{ e . first } (#{ e [ 1 ..-1 ] . join ( ', ' ) } )" : e . first
244+ else
245+ e . name
246+ end
247+ end . join ( '.' ) + acting_user_string
248+ rescue
249+ vector . to_s + acting_user_string
250+ end
251+
232252 def start_timing ( &block )
233253 ServerDataCache . class . start_timing ( &block )
234254 end
@@ -245,11 +265,11 @@ def apply_method_to_cache(method)
245265 cache_item . apply_star || representative
246266 elsif method == "*all"
247267 # if we secure the collection then we assume its okay to read the ids
248- secured_value = cache_item . value . __secure_collection_check ( @acting_user )
268+ secured_value = cache_item . value . __secure_collection_check ( cache_item )
249269 cache_item . build_new_cache_item ( timing ( :active_record ) { secured_value . collect { |record | record . id } } , method , method )
250270 elsif method == "*count"
251- secured_value = cache_item . value . __secure_collection_check ( @acting_user )
252- cache_item . build_new_cache_item ( timing ( :active_record ) { cache_item . value . __secure_collection_check ( @acting_user ) . count } , method , method )
271+ secured_value = cache_item . value . __secure_collection_check ( cache_item )
272+ cache_item . build_new_cache_item ( timing ( :active_record ) { cache_item . value . __secure_collection_check ( cache_item ) . count } , method , method )
253273 elsif preloaded_value = @preloaded_records [ cache_item . absolute_vector + [ method ] ]
254274 # no security check needed since we already evaluated this
255275 cache_item . build_new_cache_item ( preloaded_value , method , method )
@@ -273,10 +293,10 @@ def apply_method_to_cache(method)
273293 else
274294 raise "method missing"
275295 end
276- rescue Exception => e # this check may no longer be needed as we are quite explicit now on which methods we apply
277- # ReactiveRecord::Pry::rescued(e)
278- ::Rails . logger . debug "\033 [0;31;1mERROR: HyperModel exception caught when applying #{ method } to db object #{ cache_item . value } : #{ e } \033 [0;30;21m"
279- raise e , "HyperModel fetching records failed, exception caught when applying #{ method } to db object #{ cache_item . value } : #{ e } " , e . backtrace
296+ # rescue Exception => e # this check may no longer be needed as we are quite explicit now on which methods we apply
297+ # # ReactiveRecord::Pry::rescued(e)
298+ # # ::Rails.logger.debug "\033[0;31;1mERROR: HyperModel exception caught when applying #{method} to db object #{cache_item.value}: #{e}\033[0;30;21m"
299+ # raise e, "HyperModel fetching records failed, exception caught when applying #{method} to db object #{cache_item.value}: #{e}", e.backtrace
280300 end
281301 end
282302 end
@@ -296,7 +316,7 @@ def aggregation?(method)
296316 end
297317
298318 def apply_star
299- if @value && @value . __secure_collection_check ( @acting_user ) && @value . length > 0
319+ if @value && @value . __secure_collection_check ( self ) && @value . length > 0
300320 i = -1
301321 @value . inject ( nil ) do |representative , current_value |
302322 i += 1
0 commit comments