Sha256: 367b50fc5800d47d501ebd90a7003772c576bbf3adbe8af243ce1c5c036904b1

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

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

    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

    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

1 entries across 1 versions & 1 rubygems

Version Path
unidom-geo-1.4.4 app/models/unidom/geo/concerns/as_located.rb