-
-
Save onethirtyfive/135968f3c0dce2f782fcd0338d5194ae 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 Base | |
A_VALUE = 2 | |
def foo | |
end | |
end | |
module Refiner | |
refine Base do | |
def foo | |
old_value = super | |
if old_value % 2 != 0 | |
raise "NOT EVEN" | |
end | |
end | |
end | |
end | |
class Sub < Base | |
def foo | |
super | |
return A_VALUE | |
end | |
end | |
class BadSub < Base | |
def foo | |
super | |
return A_VALUE + 1 | |
end | |
end | |
using Refiner | |
Sub.new.foo | |
BadSub.new.foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment