item_builder 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/item_builder.rb +46 -1
- data/lib/item_builder/modes.rb +4 -0
- data/lib/item_builder/modes/quantity_service.rb +2 -2
- data/lib/item_builder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f8232744164229bf81eaf5dc1069c9f56fd83d110c48d51088a2284e52dd2e5
|
4
|
+
data.tar.gz: fbbb12a28d964bc6badd2c5914ca8b0dab476576fb0d8009c4fff230d8ff8afe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f51bf30b10eb630cf99ec445ff4192ee150c32ac5b731a007103ab9329e47bd6fb4f49179b7762f302827bbe3a7ad9e72099465c3925984bf9278be58c316273
|
7
|
+
data.tar.gz: 3c2ecb37ead73a59dd4b9158fa66eadbdd196d77c58eee56b23b859cd57c02a76d3a9c251313dda44ceea88d1cd8f72d382d331e5767a08205c679b004e74f71
|
data/lib/item_builder.rb
CHANGED
@@ -10,13 +10,58 @@ require 'item_models'
|
|
10
10
|
|
11
11
|
module ItemBuilder
|
12
12
|
class << self
|
13
|
+
attr_reader :listing_ids
|
14
|
+
attr_reader :listings
|
15
|
+
attr_reader :mode
|
16
|
+
attr_reader :wh_spaces
|
17
|
+
attr_reader :variants
|
18
|
+
attr_reader :variant_ids
|
13
19
|
def build(listing_ids, mode)
|
20
|
+
@listing_ids = listing_ids
|
14
21
|
@mode = mode
|
15
|
-
|
22
|
+
mode_check
|
23
|
+
end
|
24
|
+
|
25
|
+
def mode_check
|
26
|
+
if mode == :quantity
|
27
|
+
quantity_mode
|
28
|
+
else
|
29
|
+
default
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def quantity_mode
|
34
|
+
listings.map do |listing|
|
35
|
+
modes[mode].new(
|
36
|
+
listing: listing,
|
37
|
+
wh_spaces: wh_spaces,
|
38
|
+
variants: variants
|
39
|
+
).perform
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def default
|
44
|
+
listings.map do |listing|
|
16
45
|
modes[mode].new(listing: listing).perform
|
17
46
|
end
|
18
47
|
end
|
19
48
|
|
49
|
+
def wh_spaces
|
50
|
+
@wh_spaces ||= WarehouseSpace.where(item_variant_id: variant_ids)
|
51
|
+
end
|
52
|
+
|
53
|
+
def variants
|
54
|
+
@variants ||= Variant.where(id: variant_ids)
|
55
|
+
end
|
56
|
+
|
57
|
+
def variant_ids
|
58
|
+
@variant_ids ||= listings.map(&:variant_id).uniq
|
59
|
+
end
|
60
|
+
|
61
|
+
def listings
|
62
|
+
@listings ||= VariantListing.where(id: listing_ids)
|
63
|
+
end
|
64
|
+
|
20
65
|
def modes
|
21
66
|
{
|
22
67
|
price: ItemBuilder::Modes::PriceService,
|
data/lib/item_builder/modes.rb
CHANGED
@@ -9,8 +9,12 @@ require 'item_builder/modes/update_service'
|
|
9
9
|
module ItemBuilder
|
10
10
|
module Modes
|
11
11
|
attr_reader :listing
|
12
|
+
attr_reader :wh_spaces
|
13
|
+
attr_reader :variants
|
12
14
|
def initialize(args)
|
13
15
|
@listing = args.fetch(:listing)
|
16
|
+
@wh_spaces = args.fetch(:wh_spaces) || []
|
17
|
+
@variants = args.fetch(:variants) || []
|
14
18
|
end
|
15
19
|
|
16
20
|
def base
|
@@ -55,11 +55,11 @@ module ItemBuilder
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def warehouse
|
58
|
-
|
58
|
+
wh_spaces.select {|ws| ws.item_variant_id == listing.variant_id }.first
|
59
59
|
end
|
60
60
|
|
61
61
|
def variant
|
62
|
-
|
62
|
+
variants.select {|v| v.id == listing.variant_id }.first
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/item_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okaaryanata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|