This file contains 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 Abc | |
def initialize | |
@thing = {"foo" => "bar"} | |
end | |
end | |
$stack = [{:config => {}}] | |
set_trace_func lambda { |event, file, line, id, binding, classname| | |
printf("%8s %s:%-2d %10s %8s\n", event, file, line, id, classname) |
This file contains 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
module Proxies | |
# ProxyHash can be used when there is a need to have procs inside hashes, as it executes all procs before returning the hash | |
# ==== Example | |
# Proxies::ProxyHash.new(:company_id => lambda{logged_user.try(:company_id)}) | |
class ProxyHash < ::Hash | |
instance_methods.each{|m| undef_method m unless m =~ /(^__|^nil\?$|^method_missing$|^object_id$|proxy_|^respond_to\?$|^send$)/} | |
def [](_key) | |
call_hash_procs(@target, @original_hash) | |
ProxyHash.new(@original_hash[_key]) |