unidom-standard 1.0.1 → 1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0852f19358dbf277fc59fc8491474c620c269dc3
4
- data.tar.gz: d126696e2cebc422f41d66ac3c215d2d1e544331
3
+ metadata.gz: 01720c46356631eb0988ead8a6c9ac0b3c5b6cdc
4
+ data.tar.gz: d61712c2fb0d996d24136040930c20e4877db93f
5
5
  SHA512:
6
- metadata.gz: 354283ab9b72e09d5f1a88c783d24c2c07244c666ac13ef657baa7a0cd96ce0b1bdebd1e30ae30717d7ba1bcb570c6272619964f6dc8bd202d6503988fe72f70
7
- data.tar.gz: 9faba9c0146a4d5a582d9e3b1cdef972041ddd0f5a9f3b2e55cff1b3d420ea32190260e2eee4184b5b532e1538345516076769deb13ee588ca4fc0c775f5b7e8
6
+ metadata.gz: 057cca46172492ee3ecb7ffa4003036bef2c4a101b3709f71d2b779d7534e990fb564756b165c3adcac72eca0582963cd203a0a64ec635890250fadd3462544b
7
+ data.tar.gz: 3d4fd6057b406e90bc410bcc7fb98778f8231543fc8e1276838ecb211e2c4a5bf32eed07a3414a523ef4d9336c04f1ef82a36bf406114b13b0e9a48d5cc6b41a
data/README.md CHANGED
@@ -32,3 +32,21 @@ gbk.target_standards.merge(Unidom::Standard::StandardAssociating.association_cod
32
32
  # GBK revise GB2312
33
33
  Unidom::Standard::StandardAssociating.associate! gbk, with: gb2312, due_to: 'REVS'
34
34
  ```
35
+
36
+
37
+
38
+ ## Inlcude the Concerns
39
+ ```ruby
40
+ include Unidom::Standard::Concerns::AsSourceStandard
41
+ include Unidom::Standard::Concerns::AsTargetStandard
42
+ ```
43
+
44
+ ### As Source Standard concern
45
+ The As Source Standard concern do the following tasks for the includer automatically:
46
+ 1. Define the has_many :target_associatings macro as: ``has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id``
47
+ 2. Define the has_many :target_standards macro as: ``has_many :target_standards, through: :target_associatings, source: :target``
48
+
49
+ ### As Target Standard concern
50
+ The As Target Standard concern do the following tasks for the includer automatically:
51
+ 1. Define the has_many :source_associatings macro as: ``has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id``
52
+ 2. Define the has_many :source_standards macro as: ``has_many :source_standards, through: :source_associatings, source: :source``
@@ -0,0 +1,15 @@
1
+ module Unidom::Standard::Concerns::AsSourceStandard
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id
8
+ has_many :target_standards, through: :target_associatings, source: :target
9
+
10
+ end
11
+
12
+ module ClassMethods
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ module Unidom::Standard::Concerns::AsTargetStandard
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id
8
+ has_many :source_standards, through: :source_associatings, source: :source
9
+
10
+ end
11
+
12
+ module ClassMethods
13
+ end
14
+
15
+ end
@@ -12,15 +12,12 @@ class Unidom::Standard::Standard < ActiveRecord::Base
12
12
  self.table_name = 'unidom_standards'
13
13
 
14
14
  include Unidom::Common::Concerns::ModelExtension
15
+ include Unidom::Standard::Concerns::AsSourceStandard
16
+ include Unidom::Standard::Concerns::AsTargetStandard
15
17
 
16
18
  validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
17
19
  validates :number, presence: true, length: { in: 2..self.columns_hash['number'].limit }, uniqueness: true
18
20
 
19
21
  scope :number_is, ->(number) { where number: number }
20
22
 
21
- has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id # as: :source
22
- has_many :target_standards, through: :target_associatings, source: :target
23
- has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id # as: :target
24
- has_many :source_standards, through: :source_associatings, source: :source
25
-
26
23
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Standard
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: '1.1'
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-08-15 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -40,6 +40,8 @@ files:
40
40
  - app/assets/stylesheets/unidom/standard/application.css
41
41
  - app/controllers/unidom/standard/application_controller.rb
42
42
  - app/helpers/unidom/standard/application_helper.rb
43
+ - app/models/unidom/standard/concerns/as_source_standard.rb
44
+ - app/models/unidom/standard/concerns/as_target_standard.rb
43
45
  - app/models/unidom/standard/standard.rb
44
46
  - app/models/unidom/standard/standard_associating.rb
45
47
  - app/views/layouts/unidom/standard/application.html.erb