Sha256: 67fe3ba65036f27fe1dfbbe6ebc3881beea9f3e6680455acfe39bd6d3bd46f2c
Contents?: true
Size: 628 Bytes
Versions: 16
Compression:
Stored size: 628 Bytes
Contents
class UserLocation < AbstractAdapter belongs_to :user belongs_to :location belongs_to :detectable, polymorphic: true validates_inclusion_of :detectable_type, in: %w(LocationBeacon LocationGps) default_scope { includes(:detectable).order("created_at desc") } def coords=(c) # convenience method to set coordinates by an array of [lat,lng,alt] self.lat = c[0] self.lng = c[1] self.alt = c[2] end def beacon detectable.is_a?(LocationBeacon) ? detectable : {} end def distance if location.gps && lat && lng location.gps.distance_from(lat,lng) else nil end end end
Version data entries
16 entries across 16 versions & 1 rubygems