Is there something like Python __getattr__
for Ruby? In Python, obj.__getattr__
is called when an undefined attribute (method or property) is referenced. I found method_missing
in Ruby but it doesn't work for properties.
My use case is: I'm testing Mirah as a JRuby -> Java compiler. In standard JRuby, the Swing methods and attributes are "Rubyfied" (eg: label.setText "x" => label.text = "x"), but not in Mirah, because Mirah doesn't have a propietary runtime library like JRuby. Then, I want to get the attribute references in runtime and map each call to the corresponding Swing method (label.text => label.getText() / label.text = "x" => label.setText("x") ).