Created
July 31, 2009 18:17
-
-
Save ymendel/159355 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
Thing = Struct.new(:a, :b, :c) do | |
def some_thing | |
end | |
end | |
class Thing | |
attr_accessor :d | |
alias_method :old_brackets, :[] | |
def [](m) | |
if m.to_s == 'd' | |
self.d | |
else | |
old_brackets(m) | |
end | |
end | |
alias_method :old_brackets_equal, :[]= | |
def []=(m, v) | |
if m.to_s == 'd' | |
self.d = v | |
else | |
old_brackets_equal(m, v) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment