Skip to content

Instantly share code, notes, and snippets.

@daryllxd
Created March 14, 2014 15:40
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 daryllxd/9550257 to your computer and use it in GitHub Desktop.
Save daryllxd/9550257 to your computer and use it in GitHub Desktop.
class Proxy
attr_accessor :messages
def initialize(target_object)
@object = target_object
@messages = []
end
def method_missing(method_name, *args, &block)
@messages.push method_name
@object.send(method_name, *args, &block)
end
def called?(method)
@messages.include? method
end
def number_of_times_called(method)
@messages.count{|obj| obj == method}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment