unidom-inventory 0.1 → 0.2

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: 8f5e96fcfc7b41846527bd595a78e243fa39cf4c
4
- data.tar.gz: 279f467231b3b984e6687990c887dcd8358d22a7
3
+ metadata.gz: fdf84be168491311c58b77b8fbb9382800280ae1
4
+ data.tar.gz: 9fba154176b6e83e871735e4acf0575226d6526d
5
5
  SHA512:
6
- metadata.gz: b621d882e9d4d9efd4ccbdbc2fb220e09083cdff7c0e47a289d64bfad8f1cd6fadca34fcc8c9720c7cd9297fe6648f817f54322ae71f06b4d6ca67f537165b56
7
- data.tar.gz: cffce1cddbb64531485eed9c6e4e1dac8b5ce2dbe3dec13626f364337d90cb691a530f0e7314375980ccdaeaf2f555977ccfe425ab49e73122937d12a27dda20
6
+ metadata.gz: d302a83f5e6d680b34e2a02221e78e2c1a74c05b471df2c0bee056552bc01864d8ffe446242712da9e593196d6909bfa886ed2a1124b1e3dd155c049f20f4a40
7
+ data.tar.gz: 202da42dd291b209056e4ff0e0afddfb6a93565b549c21fa3821d34c695288cc46d0bfc93038330de5c8ad9f78951e5a055d421194e947a77f086057c1de6393
data/README.md CHANGED
@@ -10,19 +10,39 @@ Unidom (统一领域对象模型)是一系列的领域模型引擎。库存领
10
10
  Check out the [Road Map](ROADMAP.md) to find out what's the next.
11
11
  Check out the [Change Log](CHANGELOG.md) to find out what's new.
12
12
 
13
+
14
+
13
15
  ## Usage in Gemfile
16
+
14
17
  ```ruby
15
18
  gem 'unidom-inventory'
16
19
  ```
17
20
 
21
+
22
+
18
23
  ## Run the Database Migration
24
+
19
25
  ```shell
20
26
  rake db:migrate
21
27
  ```
22
28
  The migration versions start with 200209.
23
29
 
30
+
31
+
24
32
  ## Call the Model
25
33
  ```ruby
26
34
  Unidom::Inventory::SerializedInventoryItem.valid_at.alive.first
27
35
  Unidom::Inventory::GroupedInventoryItem.valid_at.alive.first
28
36
  ```
37
+
38
+
39
+
40
+ ## Include the Concerns
41
+ ```ruby
42
+ include Unidom::Inventory::AsInventoryItem
43
+ ```
44
+
45
+ ### As Inventory Item concern
46
+ The As Inventory Item concern do the following tasks for the includer automatically:
47
+ 1. Define the belongs_to :stored macro as: ``belongs_to :stored, polymorphic: true``
48
+ 2. Define the belongs_to :store macro as: ``belongs_to :store, polymorphic: true``
@@ -0,0 +1,15 @@
1
+ module Unidom::Inventory::Concerns::AsInventoryItem
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ belongs_to :stored, polymorphic: true
8
+ belongs_to :store, polymorphic: true
9
+
10
+ end
11
+
12
+ module ClassMethods
13
+ end
14
+
15
+ end
@@ -4,9 +4,7 @@ class Unidom::Inventory::GroupedInventoryItem < ActiveRecord::Base
4
4
  self.table_name = 'unidom_grouped_inventory_items'
5
5
 
6
6
  include Unidom::Common::Concerns::ModelExtension
7
-
8
- belongs_to :stored, polymorphic: true
9
- belongs_to :store, polymorphic: true
7
+ include Unidom::Inventory::Concerns::AsInventoryItem
10
8
 
11
9
  validates :quantity, presence: true, numericality: true
12
10
 
@@ -4,9 +4,7 @@ class Unidom::Inventory::SerializedInventoryItem < ActiveRecord::Base
4
4
  self.table_name = 'unidom_serialized_inventory_items'
5
5
 
6
6
  include Unidom::Common::Concerns::ModelExtension
7
-
8
- belongs_to :stored, polymorphic: true
9
- belongs_to :store, polymorphic: true
7
+ include Unidom::Inventory::Concerns::AsInventoryItem
10
8
 
11
9
  validates :serial_number, presence: true, length: { in: 2..columns_hash['serial_number'].limit }
12
10
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Inventory
3
- VERSION = '0.1'.freeze
3
+ VERSION = '0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.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-09-11 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -40,6 +40,7 @@ files:
40
40
  - app/assets/stylesheets/unidom/inventory/application.css
41
41
  - app/controllers/unidom/inventory/application_controller.rb
42
42
  - app/helpers/unidom/inventory/application_helper.rb
43
+ - app/models/unidom/inventory/concerns/as_inventory_item.rb
43
44
  - app/models/unidom/inventory/grouped_inventory_item.rb
44
45
  - app/models/unidom/inventory/serialized_inventory_item.rb
45
46
  - app/views/layouts/unidom/inventory/application.html.erb