unidom-price 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/models/unidom/price/concerns/as_priced.rb +10 -0
- data/app/models/unidom/price/concerns/as_pricer.rb +10 -0
- data/lib/unidom/price/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: c75e12e56ca3e86473e2a7aa901bbb6d572d4375
|
4
|
+
data.tar.gz: a9bda6ba710a320dd033ba4ec599aa5fe59721ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fb5a5a334c087cef62849ccd0d385d37386a6566634ed21ca40666d78b3c9cbfe0de5b6630cc29c1a3767b03104c45e2a8b417ee26ff0bf15d140d249709604
|
7
|
+
data.tar.gz: 1aab7bdb3ed4f1ae3e861c2a15bf2389f5c8161d656028bfc3d2b181b3add87bc40c4fb46f25cdeecd8135702bb7e62abdd557f5911974fb147007073df01705
|
data/README.md
CHANGED
@@ -65,7 +65,9 @@ include Unidom::Price::Concerns::AsPricer
|
|
65
65
|
### As Priced
|
66
66
|
The As Priced concern do the following tasks for the includer automatically:
|
67
67
|
1. Define the has_many :prices macro as: ``has_many :prices, class_name: 'Unidom::Price::Price', as: :priced``
|
68
|
+
2. Define the #is_priced! method as: ``is_priced!(amount, by: nil, at: Time.now)``
|
68
69
|
|
69
70
|
### As Pricer
|
70
71
|
The As Priced concern do the following tasks for the includer automatically:
|
71
72
|
1. Define the has_many :pricings macro as: ``has_many :pricings, class_name: 'Unidom::Price::Price', as: :pricer``
|
73
|
+
2. Define the #price! method as: ``price!(it, amount, at: Time.now)``
|
@@ -6,6 +6,16 @@ module Unidom::Price::Concerns::AsPriced
|
|
6
6
|
|
7
7
|
has_many :prices, class_name: 'Unidom::Price::Price', as: :priced
|
8
8
|
|
9
|
+
def is_priced!(amount, by: nil, at: Time.now)
|
10
|
+
pricing = prices.valid_at(now: at).alive.first
|
11
|
+
pricing.soft_destroy if pricing.present?
|
12
|
+
prices.create! pricer: by, amount: amount, opened_at: at
|
13
|
+
end
|
14
|
+
|
15
|
+
#def is_priced?(at: Time.now)
|
16
|
+
# prices.valid_at(now: at).alive.exists?
|
17
|
+
#end
|
18
|
+
|
9
19
|
end
|
10
20
|
|
11
21
|
module ClassMethods
|
@@ -6,6 +6,16 @@ module Unidom::Price::Concerns::AsPricer
|
|
6
6
|
|
7
7
|
has_many :pricings, class_name: 'Unidom::Price::Price', as: :pricer
|
8
8
|
|
9
|
+
def price!(it, amount, at: Time.now)
|
10
|
+
pricing = pricings.priced_is(it).valid_at(now: at).alive.first
|
11
|
+
pricing.soft_destroy if pricing.present?
|
12
|
+
pricings.create! priced: it, amount: amount, opened_at: at
|
13
|
+
end
|
14
|
+
|
15
|
+
#def price?(it, at: Time.now)
|
16
|
+
# pricings.priced_is(it).valid_at(now: at).alive.exists?
|
17
|
+
#end
|
18
|
+
|
9
19
|
end
|
10
20
|
|
11
21
|
module ClassMethods
|
data/lib/unidom/price/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-price
|
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
|