Skip to content

Instantly share code, notes, and snippets.

@Amokrane
Created May 22, 2011 12:37
Show Gist options
  • Save Amokrane/985430 to your computer and use it in GitHub Desktop.
Save Amokrane/985430 to your computer and use it in GitHub Desktop.
Put your method_missing inside a module
# This snippet is taken from:
# "The Polite Programmer's Guide to Ruby Etiquette"
# http://bit.ly/hrwdPY
class BlackMagicStereo < Stereo
module GreyMagic
def method_missing(name, *args)
if sym.to_s =~ /^play_(\w+)$/
system("open songs/#{$1}.m4a")
else
super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment