Sha256: b386a1b9cfea42a1fff6ac31f7d7385a1fba326e9b68ed25715c5514b31a678d
Contents?: true
Size: 1 KB
Versions: 8
Compression:
Stored size: 1 KB
Contents
## # As Located 是为地标提供的领域逻辑关注点。 module Unidom::Geo::Concerns::AsLocated extend ActiveSupport::Concern included do |includer| has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located has_many :locations, through: :locatings, source: :location ## # 将当前位置与地标 to 关联起来。如: # location = Unidom::Geo::Location.first # shop.is_located! to: location, by: current_person def is_located!(to: nil, by: nil, at: Time.now) locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at end ## # 检查当前位置与地标 to 在指定的时间 at (缺省是当前时间)是否关联起来了。 # location = Unidom::Geo::Location.first # 如: shop.is_located? to: location, at: Time.now def is_located?(to: nil, at: Time.now) locatings.location_is(to).valid_at(now: at).alive.exists? end end module ClassMethods end end
Version data entries
8 entries across 8 versions & 1 rubygems