dotfiles/ruby/irbrc

21 lines
562 B
Plaintext
Raw Normal View History

2009-07-05 01:26:55 +10:00
begin
2010-11-22 14:53:06 +11:00
require 'irbtools'
2009-07-05 01:26:55 +10:00
rescue LoadError
2010-11-22 14:53:06 +11:00
$stderr.puts "Please install 'irbtools' or add it to your Gemfile"
2009-07-05 01:26:55 +10:00
end
class Object
# Return a list of methods defined locally for a particular object. Useful
# for seeing what it does whilst losing all the guff that's implemented
# by its parents (eg Object).
def local_methods(obj = self)
(obj.methods - obj.class.superclass.instance_methods).sort
end
2009-06-10 13:02:44 +10:00
end
# Log to STDOUT if in Rails
2010-11-22 14:53:06 +11:00
if Object.const_defined?('ActiveRecord')
2009-06-10 13:02:44 +10:00
require 'logger'
2010-11-22 14:53:06 +11:00
ActiveRecord::Base.logger = Logger.new(STDOUT)
2009-06-10 13:02:44 +10:00
end