Displaying 1 result from an estimated 1 matches for "lng2".
Did you mean:
lng
2011 Feb 08
0
favorite pattern for adding functionality to an AR?
Do you have a preferred programming pattern for adding functionality to
an ActiveRecord? As an example, say I have some gnarly trig functions
for distance and bearing between pairs of latitude and longitude:
=== file: latlng.rb
module LatLng
def haversine_distance(lat1, lng1, lat2, lng2)
...
end
def bearing(lat1, lng1, lat2, lng2)
...
end
=== EOF
... and I want to mix in haversine_distance(other_ar) and
bearing(other_ar) methods into an ActiveRecord. The shim functions
would look like this:
===
def haversine_distance(other_ar)
haversine_distance(self.lat, self.lng, othe...