Skip to content

Instantly share code, notes, and snippets.

@toothrot
Created July 9, 2010 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toothrot/470108 to your computer and use it in GitHub Desktop.
Save toothrot/470108 to your computer and use it in GitHub Desktop.
a modular way to smack up eigenclass
module Farts
def farts
"pfft"
end
end
hey = "yo"
hey.farts # NoMethodError: undefined method `farts' for "yo":String
class << hey; include Farts; end # => #<Class:#<String:0x1021e9238>>
hey.farts #=> "pfft"
"barf".farts # NoMethodError: undefined method `farts' for "barf":String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment