You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Want to see a cool trick? How about loading CORE methods automagically. It’s like Ruby’s #autoload for core extensions.
require 'facets/opesc'
class Object
# This will automatically load (most) core methods
# if they are not present when called.
def method_missing(methodname, *a, &b)
methodname = OpEsc.escape(methodname)
begin
require "facets/#{class}/#{methodname}"
__send__(methodname, *a, &b)
rescue LoadError
super
end
end
end
NOTE: In version 2.8.x and less, this was possible simply via:
require 'facets-live'
As of version 3.0+ this has been deprecated for being a YAGNI. Which accounts for this “tip” if you still would like to do it.
Super Secret Tip
I moved the code into lib/more/facets/auto_core.rb, if you really want a quick way to do this.