Skip to content

Instantly share code, notes, and snippets.

@adkron
Created March 10, 2015 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adkron/cf7c065f0e4065a14bf0 to your computer and use it in GitHub Desktop.
Save adkron/cf7c065f0e4065a14bf0 to your computer and use it in GitHub Desktop.
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