class Plucky::Query
mongo_mapper patches TODO: Include overrides for distinct, update, cursor, and create
Public Instance Methods
count(*args, &blk)
click to toggle source
# File lib/patches/db/plucky.rb, line 17 def count(*args, &blk) return profile_database_operation(__callee__, filtered_inspect(), *args, &blk) end
Also aliased as: count_without_profiling
find_each(*args, &blk)
click to toggle source
# File lib/patches/db/plucky.rb, line 9 def find_each(*args, &blk) return profile_database_operation(__callee__, filtered_inspect(), *args, &blk) end
Also aliased as: find_each_without_profiling
find_one(*args, &blk)
click to toggle source
# File lib/patches/db/plucky.rb, line 13 def find_one(*args, &blk) return profile_database_operation(__callee__, filtered_inspect(args[0]), *args, &blk) end
Also aliased as: find_one_without_profiling
remove(*args, &blk)
click to toggle source
# File lib/patches/db/plucky.rb, line 21 def remove(*args, &blk) return profile_database_operation(__callee__, filtered_inspect(), *args, &blk) end
Also aliased as: remove_without_profiling
Private Instance Methods
filtered_inspect(hash = to_hash())
click to toggle source
# File lib/patches/db/plucky.rb, line 40 def filtered_inspect(hash = to_hash()) hash_string = hash.reject { |key| key == :transformer }.collect do |key, value| " #{key}: #{value.inspect}" end.join(",\n") "{\n#{hash_string}\n}" end
profile_database_operation(method, message, *args, &blk)
click to toggle source
# File lib/patches/db/plucky.rb, line 27 def profile_database_operation(method, message, *args, &blk) return self.send("#{method.id2name}_without_profiling", *args, &blk) unless SqlPatches.should_measure? start = Time.now result = self.send("#{method.id2name}_without_profiling", *args, &blk) elapsed_time = SqlPatches.elapsed_time(start) query_message = "#{@collection.name}.#{method.id2name} => #{message}" ::Rack::MiniProfiler.record_sql(query_message, elapsed_time) result end