Class: HrLite::OfficeLocation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- HrLite::OfficeLocation
- Includes:
- Audited
- Defined in:
- app/models/hr_lite/office_location.rb
Constant Summary
Constants included from Audited
Audited::REDACTED, Audited::SKIPPED_ATTRIBUTES
Class Method Summary collapse
- .covering?(lat, lng) ⇒ Boolean
-
.nearest(lat, lng) ⇒ Object
For flag notes: "1.2 km from Head Office".
Class Method Details
.covering?(lat, lng) ⇒ Boolean
12 13 14 |
# File 'app/models/hr_lite/office_location.rb', line 12 def self.covering?(lat, lng) active.any? { |office| Geo.distance_m(office.lat, office.lng, lat, lng) <= office.radius_m } end |
.nearest(lat, lng) ⇒ Object
For flag notes: "1.2 km from Head Office". Nil when no offices exist.
17 18 19 |
# File 'app/models/hr_lite/office_location.rb', line 17 def self.nearest(lat, lng) active.min_by { |office| Geo.distance_m(office.lat, office.lng, lat, lng) } end |