Created
March 14, 2014 15:40
-
-
Save daryllxd/9550257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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