Class: Unidom::Geo::Locating

Inherits:
ApplicationRecord show all
Includes:
Common::Concerns::ModelExtension
Defined in:
app/models/unidom/geo/locating.rb

Overview

Locating 是地理定位,表示地理位置和被定位物体之间的关联。

Class Method Summary collapse

Class Method Details

.locate!(location: nil, located: nil, locator: nil, opened_at: Time.now) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'app/models/unidom/geo/locating.rb', line 17

def self.locate!(location: nil, located: nil, locator: nil, opened_at: Time.now)
  attributes = { opened_at: opened_at }
  if locator.present?
    attributes[:locator] = locator
  else
    attributes[:locator_id]   = Unidom::Common::NULL_UUID
    attributes[:locator_type] = ''
  end
  self.located_is(located).location_is(location).valid_at.alive.first_or_create! attributes
end