The following code does two things:
- Checks to see if the item has the key “checkins”
- Gets the checkins value if it has the key
I really don’t like making two API calls for this. Its really slowed my code down but I’m forced to because if I make the API call for checkins and the key doesn’t exist, then my code blows up. There must be a better way to do this.
if graph.get_object(self.place_id).has_key?("checkins")
checkins = graph.get_object(self.place_id)["checkins"] - self.checkins
else
checkins = self.checkins
end
1 Answer