unidom-article_number 1.3 → 1.4

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: 7713f349391cad8f08ee311e87b7e21fd6cb6778
4
- data.tar.gz: f089924d0e6865d3a2613fe2d717ab99359e885d
3
+ metadata.gz: a29fd6d5c6f21d2016c5faa65052dc1dc9dc3ace
4
+ data.tar.gz: bf76bf71a94e1301eaab9877c90e3f4fd671e9df
5
5
  SHA512:
6
- metadata.gz: eef21de0f53df79eac176265016f7f7d9e99fc9307974144bcb03b12772bc899d6029306ac717624d7320a0f4d2cf84865fd99b55d689e5b12acb542d5fadf0f
7
- data.tar.gz: c926e8bbe8559b96baac2b243807314253f92edeb5acf9b0e765cb9c2c0c3f79d426ab900f185e1f146d7e56c25460cee63f8ac4a873565bbff3023b3912d4e8
6
+ metadata.gz: 05c287260d33edcd24f5e3f255f247e53910ad6ca8c267b30d04cba92cd0b4c5ecf80c3f03a8eaa6a50e0ef9c171345a2e0d069580cc5931da2b3d96865fa302
7
+ data.tar.gz: db7529debdbe029f8338d4eead0fced65434ee908a42576c7018be68335401629762f69a33beb773a6fa3c86a03d564cc56168750cdac3a344897ed6d2a46e35
data/README.md CHANGED
@@ -44,13 +44,14 @@ include Unidom::ArticleNumber::Concerns::AsEan8Marked
44
44
  ### As Barcode concern
45
45
  The As Barcode concern do the following tasks for the includer automatically:
46
46
  1. Define the has_many :markings macro as: ``has_many :markings, class_name: 'Unidom::ArticleNumber::Marking', as: :barcode``
47
- 2. Define the has_many :marked_products macro as: ``has_many :marked_products, through: :markings, source: :marked, source_type: 'Unidom::Product::Product'``
48
- 3. Define the #mark! method as: ``def mark!(marked, by: nil, at: Time.now)``
47
+ 2. Define the #mark! method as: ``def mark!(marked, by: nil, at: Time.now)``
48
+ 3. Define the #mark? mathod as: ``def mark?(marked, at: Time.now)``
49
49
 
50
50
  ### As Marked concern
51
51
  The As Marked concern do the following tasks for the includer automatically:
52
52
  1. Define the has_many :markings macro as: ``has_many :markings, class_name: 'Unidom::ArticleNumber::Marking', as: :marked``
53
53
  2. Define the #is_marked! method as: ``def is_marked!(as: nil, by: nil, at: Time.now)``
54
+ 3. Define the #is_marked? method as: ``def is_marked?(as: nil, at: Time.now)``
54
55
 
55
56
  ### As EAN-13 Marked concern
56
57
  The As EAN-13 Marked concern do the following tasks for the includer automatically:
@@ -2,7 +2,7 @@ module Unidom::ArticleNumber::Concerns::AsBarcode
2
2
 
3
3
  extend ActiveSupport::Concern
4
4
 
5
- self.included do |includer|
5
+ included do |includer|
6
6
 
7
7
  has_many :markings, class_name: 'Unidom::ArticleNumber::Marking', as: :barcode
8
8
  has_many :marked_products, through: :markings, source: :marked, source_type: 'Unidom::Product::Product'
@@ -14,6 +14,12 @@ module Unidom::ArticleNumber::Concerns::AsBarcode
14
14
  markings.create! marked: marked, marker: by, opened_at: at
15
15
  end
16
16
 
17
+ def mark?(marked, at: Time.now)
18
+ raise ArgumentError.new('The marked argument is required.') if marked.blank?
19
+ raise ArgumentError.new('The at argument is required.' ) if at.blank?
20
+ markings.marked_is(marked).valid_at(now: at).alive.exists?
21
+ end
22
+
17
23
  end
18
24
 
19
25
  end
@@ -2,7 +2,7 @@ module Unidom::ArticleNumber::Concerns::AsMarked
2
2
 
3
3
  extend ActiveSupport::Concern
4
4
 
5
- self.included do |includer|
5
+ included do |includer|
6
6
 
7
7
  has_many :markings, class_name: 'Unidom::ArticleNumber::Marking', as: :marked
8
8
 
@@ -13,6 +13,12 @@ module Unidom::ArticleNumber::Concerns::AsMarked
13
13
  markings.create! barcode: as, marker: by, opened_at: at
14
14
  end
15
15
 
16
+ def is_marked?(as: nil, at: Time.now)
17
+ raise ArgumentError.new('The as argument is required.') if as.blank?
18
+ raise ArgumentError.new('The at argument is required.') if at.blank?
19
+ markings.barcode_is(as).valid_at(now: at).alive.exists?
20
+ end
21
+
16
22
  end
17
23
 
18
24
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module ArticleNumber
3
- VERSION = '1.3'.freeze
3
+ VERSION = '1.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-article_number
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
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-29 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common