warehouse_items 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7ae3eb84eaf2129459844170902c41896f8bd6e
4
- data.tar.gz: b83f135e3ef919864e78b30b99c1e326a396e396
3
+ metadata.gz: 4b89d5f0f304a6888274847e417e27c74fae9444
4
+ data.tar.gz: cbe617fabef2b617691855d6d629bd00e8d27bc2
5
5
  SHA512:
6
- metadata.gz: bf6e08cce5ba858901229893f7b6e091bfbf1af37b289367bc6e25c6262dfe55af9bfcc6ffeef6d2ad1d9cc33e08f16d1ab66d2ca70dfdc25b54e6a9d6ade52a
7
- data.tar.gz: 8cf0a6c1296f0d4a34982842dcf445ae5560b645407eeecaf3cd42568393b0bafbaa673f2f2a69b4de9d17e30501ddf8307dc2d5add040ef1094ec50ceec9604
6
+ metadata.gz: 31033a056576526da3ba4b74399b46189af5d745cb522b57e1b8383b20e9ad247e0aef131b0ac47e94b2842650200d437a949a17c780674e6d441868f42ad64f
7
+ data.tar.gz: 9a23c3aed31ac2b1d0ea25f64ffc0ad85932fee7bba92068d808883a2959d1c6e2b58c812be2d44a73c726935cfecacb5482cce7a94cf55ac69d4e7e2abf3664
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- warehouse_items (0.2.0)
4
+ warehouse_items (0.3.0)
5
5
  activesupport
6
6
 
7
7
  GEM
data/lib/warehouse.rb CHANGED
@@ -2,7 +2,6 @@ require "warehouse/version"
2
2
  require 'active_support/core_ext/object'
3
3
  require 'active_support/core_ext/class'
4
4
  require 'active_support'
5
- require "warehouse/item/base"
6
5
  require "warehouse/item/code"
7
6
  require "warehouse/item/barcode"
8
7
  require "warehouse/item/random"
@@ -1,26 +1,42 @@
1
1
  module Warehouse
2
2
  module Item
3
- class Barcode < Base
4
- def initialize(*)
5
- super
6
- self.code_type = :barcode
3
+ Barcode = Struct.new(:barcode, :title, :qty) do
4
+
5
+ def barcode?
6
+ true
7
+ end
8
+
9
+ def code?
10
+ false
11
+ end
12
+
13
+ def type
14
+ 'single'
7
15
  end
8
16
 
9
- def barcode
10
- code_or_barcode
17
+ def random?
18
+ false
11
19
  end
12
20
 
13
- def code
14
- raise NoMethodError, "use #barcode instead."
21
+ def single?
22
+ true
15
23
  end
16
24
 
17
25
  def to_h
18
26
  {
19
- 'barcode' => code_or_barcode,
27
+ 'barcode' => barcode,
20
28
  'title' => title,
21
29
  'qty' => qty
22
30
  }
23
31
  end
32
+
33
+ def deep_dup
34
+ self.class.new(barcode, title, qty)
35
+ end
36
+
37
+ # 給 form 用的
38
+ def persisted?; false end
39
+ def product; end
24
40
  end
25
41
  end
26
42
  end
@@ -1,22 +1,42 @@
1
1
  module Warehouse
2
2
  module Item
3
- class Code < Base
4
- def initialize(*)
5
- super
6
- self.code_type = :code
3
+ Code = Struct.new(:code, :title, :qty, :price) do
4
+
5
+ def barcode?
6
+ false
7
+ end
8
+
9
+ def code?
10
+ true
11
+ end
12
+
13
+ def type
14
+ 'single'
7
15
  end
8
16
 
9
- def code
10
- code_or_barcode
17
+ def random?
18
+ false
19
+ end
20
+
21
+ def single?
22
+ true
11
23
  end
12
24
 
13
25
  def to_h
14
26
  {
15
- 'code' => code_or_barcode,
27
+ 'code' => code,
16
28
  'title' => title,
17
29
  'qty' => qty
18
30
  }
19
31
  end
32
+
33
+ def deep_dup
34
+ self.class.new(code, title, qty, price)
35
+ end
36
+
37
+ # 給 form 用的
38
+ def persisted?; false end
39
+ def product; end
20
40
  end
21
41
  end
22
42
  end
@@ -1,3 +1,3 @@
1
1
  module Warehouse
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warehouse_items
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddie Li
@@ -98,7 +98,6 @@ files:
98
98
  - bin/setup
99
99
  - lib/warehouse.rb
100
100
  - lib/warehouse/item/barcode.rb
101
- - lib/warehouse/item/base.rb
102
101
  - lib/warehouse/item/code.rb
103
102
  - lib/warehouse/item/random.rb
104
103
  - lib/warehouse/list.rb
@@ -1,36 +0,0 @@
1
- module Warehouse
2
- module Item
3
- Base = Struct.new(:code_or_barcode, :title, :qty, :price) do
4
- attr_accessor :code_type
5
- attr_accessor :items
6
-
7
- def barcode?
8
- code_type == :barcode
9
- end
10
-
11
- def code?
12
- code_type == :code
13
- end
14
-
15
- def type
16
- 'single'
17
- end
18
-
19
- def random?
20
- false
21
- end
22
-
23
- def single?
24
- true
25
- end
26
-
27
- def deep_dup
28
- self.class.new(code_or_barcode, title, qty, price)
29
- end
30
-
31
- # 給 form 用的
32
- def persisted?; false end
33
- def product; end
34
- end
35
- end
36
- end