Last active
August 29, 2015 14:01
-
-
Save Dispader/e27e7f497414e15ad5fb to your computer and use it in GitHub Desktop.
final
This file contains hidden or 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_reader :messages | |
| def initialize(target_object) | |
| @object = target_object | |
| @messages = [] | |
| end | |
| def called?(name) | |
| @messages.include?(name) | |
| end | |
| def number_of_times_called(name) | |
| @messages.count(name) | |
| end | |
| def method_missing(name, *args, &block) | |
| @messages << name | |
| @object.send(name, *args, &block) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment