Skip to content

Instantly share code, notes, and snippets.

@hexgnu
Created August 29, 2011 20:47
Show Gist options
  • Save hexgnu/1179368 to your computer and use it in GitHub Desktop.
Save hexgnu/1179368 to your computer and use it in GitHub Desktop.
Dont ever do this evar!!!
#!/usr/bin/env ruby -w
class Foo; end
f = Foo.new
f.instance_eval do
class << self
attr_accessor :baz
end
end
f.baz #=> nil
f.baz = 'zomg'
f.baz #=> 'zomg'
g = Foo.new
begin
g.baz
rescue NoMethodError
puts 'There is no method BAZ!!!'
end
begin
g.baz = 'ugh'
rescue NoMethodError
puts 'Seriously why would you ever do this?!!'
end
puts 'WHAT THE FUCK MAN'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment