Skip to content

Instantly share code, notes, and snippets.

@valachi
Created January 25, 2013 22:02
Show Gist options
  • Select an option

  • Save valachi/4638303 to your computer and use it in GitHub Desktop.

Select an option

Save valachi/4638303 to your computer and use it in GitHub Desktop.
class Stweie
ALLOWED_METHODS = [:methods, :method, :why]
def hello
'Hello'
end
instance_methods.each do |method|
undef_method method unless method_belongs?(method)
end
class_eval do
def why
'WHY'
end
end
instance_eval do
def allowed_methods
ALLOWED_METHODS
end
end
def method_missing(method_name)
puts "You've asked me to #{method_name}, but where are my money, BITCH?"
end
private
def self.method_belongs?(method_name)
ALLOWED_METHODS.include?(method) or method =~ /^__/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment