Created
March 10, 2015 16:41
-
-
Save adkron/cf7c065f0e4065a14bf0 to your computer and use it in GitHub Desktop.
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 Reaction | |
def initialize(yield_to) | |
self.yield_to = yield_to | |
end | |
def method_missing(method_name, *) | |
if yieldable?(method_name) | |
yield if block_given? | |
end | |
end | |
def respond_to_missing(*) | |
true | |
end | |
def ==(other) | |
self.yield_to == other.yield_to | |
end | |
def yieldable?(method_name) | |
yield_to == method_name | |
end | |
private | |
attr_accessor :yield_to | |
protected :yield_to | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment