This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::ConnectionAdapters::AbstractAdapter | |
def called_by(original_caller) | |
str = original_caller.reject { |info| !info.match /#{Rails.root}/ }.first | |
str.gsub(Rails.root,'') | |
end | |
def log_info(sql, name, ms) | |
if @logger && @logger.debug? | |
name = '%s (%.1fms) %s' % [name || 'SQL', ms, called_by(caller)] | |
@logger.debug(format_log_entry(name, sql.squeeze(' '))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def method_added(symbol) | |
p caller if symbol == :h | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
$require_level = 0 | |
module Kernel | |
alias require_without_timing require | |
def require(path) | |
result = seconds = nil | |
begin | |
$require_level += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def pose_as(klass) | |
namespace = klass.to_s.split("::") | |
klass = namespace.pop | |
if namespace.any? | |
eval <<-EOT | |
module ::#{namespace.join("::")} | |
send(:remove_const, :"#{klass}") | |
#{klass} = #{self} |
NewerOlder