I’d like to see how this Java code would look in JRuby:
ParseQuery query = new ParseQuery("MyClass");
query.getInBackground(myId, new GetCallback() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
objectWasRetrievedSuccessfully(object);
} else {
objectRetrievalFailed();
}
}
});
The biggest part of confusion for me is the anonymous inner class. This is my best first guess:
query = ParseQuery.new("GameScore")
query.getInBackground("xWMyZ4YEGZ", Class.new(GetCallback) do
def done(object, e)
# ...
end
end.new)
Update: Edited based on this: http://www.ruby-forum.com/topic/188599#823271
The syntax for expressing this in JRuby is deceptively simple. JRuby has a feature called ‘closure conversion’ where a closure passed to a method can is converted into the appropriate Java interface. From the JRuby docs:
So, your code would look like:
The ‘calling Java from JRuby’ page on the JRuby wiki is a good resource for problems like these.