Amokrane
5/22/2011 - 12:37 PM

Put your method_missing inside a module

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