Skip to content

Instantly share code, notes, and snippets.

@ymendel
Created July 31, 2009 18:17
Show Gist options
  • Save ymendel/159355 to your computer and use it in GitHub Desktop.
Save ymendel/159355 to your computer and use it in GitHub Desktop.
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