unidom-geo 1.1 → 1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/app/models/unidom/geo/concerns/as_located.rb +4 -0
- data/app/models/unidom/geo/location.rb +5 -1
- data/lib/unidom/geo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d804f7b473b75141cb773b78046619750b7d4c6
|
4
|
+
data.tar.gz: ea65c588897d92dea09f9832a6d3bad8abbd653c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df39c01b430a9c26d7e5da6d7d9a3d8e8ceb856088b889a3ed1e1a978d7ea320bbf7d76ef34214f5055156b33c84e25246200dc143cab98d7a191be32bf8b895
|
7
|
+
data.tar.gz: 7844ceb083e5ce0194983aa0d3746a573732e91f0d750fa283985f192b1c2dd46f9cc6f2dd309a97b6ed4e8cff50741b549a942e06d56b7dcf5d93f893ce2e46
|
data/README.md
CHANGED
@@ -31,6 +31,9 @@ active_locatings = location.locatings.valid_at.alive
|
|
31
31
|
location.locate! shop, by: person
|
32
32
|
# or
|
33
33
|
Unidom::Geo::Locating.locate! location: location, located: shop
|
34
|
+
|
35
|
+
# Determine whether a shop was located to a given location at a given time.
|
36
|
+
location.locate? shop, at: Time.now
|
34
37
|
```
|
35
38
|
|
36
39
|
## Include the Concerns:
|
@@ -43,6 +46,7 @@ include Unidom::Geo::Concerns::AsRegion
|
|
43
46
|
The As Located concern do the following tasks for the includer automatically:
|
44
47
|
1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located``
|
45
48
|
2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
|
49
|
+
3. Define the #is_located! method as: ``is_located!(to: nil, by: nil, at: Time.now)``
|
46
50
|
|
47
51
|
### As Region concern
|
48
52
|
The As Region concern do the following tasks for the includer automatically:
|
@@ -7,6 +7,10 @@ module Unidom::Geo::Concerns::AsLocated
|
|
7
7
|
has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located
|
8
8
|
has_many :locations, through: :locatings, source: :location
|
9
9
|
|
10
|
+
def is_located!(to: nil, by: nil, at: Time.now)
|
11
|
+
locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
|
12
|
+
end
|
13
|
+
|
10
14
|
end
|
11
15
|
|
12
16
|
module ClassMethods
|
@@ -25,7 +25,11 @@ class Unidom::Geo::Location < ActiveRecord::Base
|
|
25
25
|
scope :postal_address_is, ->(postal_address) { where postal_address: postal_address }
|
26
26
|
|
27
27
|
def locate!(located, by: nil, at: Time.now)
|
28
|
-
locatings.
|
28
|
+
locatings.located_is(located).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
|
29
|
+
end
|
30
|
+
|
31
|
+
def locate?(located, at: Time.now)
|
32
|
+
locatings.located_is(located).valid_at(now: at).alive.exists?
|
29
33
|
end
|
30
34
|
|
31
35
|
end
|
data/lib/unidom/geo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|