Skip to content

Instantly share code, notes, and snippets.

@mulder
Created February 4, 2015 03:38
Show Gist options
  • Save mulder/945c9058f6ce2606ab95 to your computer and use it in GitHub Desktop.
Save mulder/945c9058f6ce2606ab95 to your computer and use it in GitHub Desktop.
def self.new(t);t.class==Class ? t.new : t;end;def method_missing(*a);c=Kernel.const_get(a[0]) rescue(nil);c ? c.new(*a[1..-1]) : super; end
class Foo
attr_reader :bar
def initialize(bar)
@bar = bar
end
end
f = new Foo(1)
f.bar
@mulder
Copy link
Author

mulder commented Feb 4, 2015

copy the first bit into irb land; then run the second bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment