unidom-shopping 0.3 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/models/unidom/shopping/shopping_cart.rb +3 -3
- data/lib/unidom/shopping/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7decfc894f0b926e40c6505d8c5f0906de185f22
|
4
|
+
data.tar.gz: 0eafbd0e27261deac2f2e1e1c46186b3e4927781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5f97406d7aac94bc254058b5827abfc63d5b0db20950c98ef79b2a15583df42e8f8cd7ad6c1491df2181ee8059b4594cc2e04f176109a807b6e08480a2d460
|
7
|
+
data.tar.gz: c067d2a5c2c807531fc9aedff7634480cdb6d7266947bf991f1e97f8ae5c6c0c0dd1e3b768b41b7f4fc5f564975443a2509645dd35fcbbe453cc501f1d9a8999
|
data/README.md
CHANGED
@@ -31,11 +31,11 @@ shopping_cart = Unidom::Shopping::ShoppingCart.create shopper: lady, shop: shop,
|
|
31
31
|
# Add Products into Shopping Cart
|
32
32
|
fish = Product.create name: 'Fish'
|
33
33
|
ball = Prdduct.create name: 'Ball'
|
34
|
-
shopping_cart.items.create shopper: lady, shopped: fish, unit_price: 39.96, quantity: 2, opened_at: Time.now
|
35
|
-
shopping_cart.items.create shopper: lady, shopped: ball, unit_price: 19.99, quantity: 1, opened_at: Time.now
|
34
|
+
shopping_cart.items.create! shopper: lady, shopped: fish, unit_price: 39.96, quantity: 2, opened_at: Time.now
|
35
|
+
shopping_cart.items.create! shopper: lady, shopped: ball, unit_price: 19.99, quantity: 1, opened_at: Time.now
|
36
36
|
# or
|
37
|
-
shopping_cart.add! fish, 39.96, 2, Time.now
|
38
|
-
shopping_cart.add! ball, 19.99
|
37
|
+
shopping_cart.add! fish, unit_price: 39.96, quantity: 2, at: Time.now
|
38
|
+
shopping_cart.add! ball, unit_price: 19.99
|
39
39
|
|
40
40
|
# Find the Shopping Cart
|
41
41
|
shopping_cart = Unidom::Shopping::ShoppingCart.shopped_by(lady).shop_is(shop).valid_at.alive.first
|
@@ -14,13 +14,13 @@ class Unidom::Shopping::ShoppingCart < ActiveRecord::Base
|
|
14
14
|
scope :shopped_by, ->(shopper) { where shopper: shopper }
|
15
15
|
scope :shop_is, ->(shop) { where shop: shop }
|
16
16
|
|
17
|
-
def add!(shopped, unit_price, quantity
|
17
|
+
def add!(shopped, by: nil, unit_price: 0, quantity: 1, at: Time.now)
|
18
18
|
item = items.shopped_is(shopped).valid_at.alive.first
|
19
19
|
if item.present?
|
20
|
-
item.attributes = { shopper: shopper, unit_price: unit_price, quantity: quantity+item.quantity }
|
20
|
+
item.attributes = { shopper: by||shopper, unit_price: unit_price, quantity: quantity+item.quantity }
|
21
21
|
item.save!
|
22
22
|
else
|
23
|
-
items.create! shopped: shopped, shopper: shopper, unit_price: unit_price, quantity: quantity, opened_at:
|
23
|
+
items.create! shopped: shopped, shopper: by||shopper, unit_price: unit_price, quantity: quantity, opened_at: at
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-shopping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
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-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|