Sha256: 9594fd812fb165f0bc6211e740b2f13611e3eaf55bd73a273dac86389cf79d9f

Contents?: true

Size: 577 Bytes

Versions: 5

Compression:

Stored size: 577 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
unidom-geo-1.4.3 app/models/unidom/geo/concerns/as_located.rb
unidom-geo-1.4.2 app/models/unidom/geo/concerns/as_located.rb
unidom-geo-1.4.1 app/models/unidom/geo/concerns/as_located.rb
unidom-geo-1.4 app/models/unidom/geo/concerns/as_located.rb
unidom-geo-1.3 app/models/unidom/geo/concerns/as_located.rb