database_consistency 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: c50d282f04ae0e4003a596551369213ea66ee986a6f2486a3761ec36af6d87b3
4
- data.tar.gz: 14141f85bb9ced24c2cf4fe69d2ace3a0aa0218e4f181846d2c0dfcf88569d9d
3
+ metadata.gz: 86853e78b9e1bb68f9e34dbea3b23de33890760a3598b954cd8e89f3ddf88193
4
+ data.tar.gz: '082c7135a3057bbe59b78d463b62fd522cfcfc3bd0c8b452bb591375d72d962d'
5
5
  SHA512:
6
- metadata.gz: 90577c3faf083a0c694ac8d1146d5980e7ff69df6be7578cb57069bf62a4bc3455c2f8b4a639ccae2b75f8db8473c3c5e1733e407ca0e3292a5610062e48313b
7
- data.tar.gz: 1d638396701af3be6591db67d5782cae92d4af14fb38a4a076834836b2b7988772ee053056247d56984f2830185dd9b7703464efabec21d99e8674b112b0abfa
6
+ metadata.gz: a82a054afba3dac8b0c75bbfaeab357f4c9f9c20d50f854cf0ae30442dbcae1dd18d4223c6e5d31545aa8927c0cd16c243bdc45aeca25102e2a74bee5da097b7
7
+ data.tar.gz: e0a898d8f10bbf2c47ec4fd397f1b2f01f4696f0ee23bcce47c6ee0d2efa4a2aa0d5caefc219f621fa14701d86fb3aecad3ff414190efbf4542360c5a7f2085c
@@ -5,7 +5,7 @@ module DatabaseConsistency
5
5
  VALIDATOR_MISSING = 'is required but do not have presence validator'.freeze
6
6
 
7
7
  def verify
8
- result(:fail, Helper.message(column, VALIDATOR_MISSING)) unless skip? || validator?
8
+ result(:fail, Helper.message(model, column, VALIDATOR_MISSING)) unless skip? || validator?
9
9
  end
10
10
 
11
11
  private
@@ -2,12 +2,13 @@ module DatabaseConsistency
2
2
  module Comparators
3
3
  # The base class for comparators
4
4
  class BaseComparator
5
- attr_reader :validator, :column
5
+ attr_reader :validator, :model, :column
6
6
 
7
7
  delegate :result, to: :report
8
8
 
9
- def initialize(validator, column)
9
+ def initialize(validator, model, column)
10
10
  @validator = validator
11
+ @model = model
11
12
  @column = column
12
13
  end
13
14
 
@@ -15,8 +16,8 @@ module DatabaseConsistency
15
16
  Report.new(validator: validator, column: column)
16
17
  end
17
18
 
18
- def self.compare(validator, column)
19
- new(validator, column).compare
19
+ def self.compare(validator, model, column)
20
+ new(validator, model, column).compare
20
21
  end
21
22
  end
22
23
  end
@@ -30,7 +30,7 @@ module DatabaseConsistency
30
30
  private
31
31
 
32
32
  def message(template = nil)
33
- Helper.message(column, template)
33
+ Helper.message(model, column, template)
34
34
  end
35
35
  end
36
36
  end
@@ -19,8 +19,8 @@ module DatabaseConsistency
19
19
  end
20
20
 
21
21
  # @return [String]
22
- def message(column, template = nil)
23
- str = "column #{column.name} of table #{column.table_name}"
22
+ def message(model, column, template = nil)
23
+ str = "column #{column.name} of table #{model.table_name}"
24
24
  str += " #{template}" if template
25
25
  str
26
26
  end
@@ -13,7 +13,7 @@ module DatabaseConsistency
13
13
  validator.attributes.map do |attribute|
14
14
  next unless (column = Helper.find_field(model, attribute.to_s))
15
15
 
16
- comparator.compare(validator, column)
16
+ comparator.compare(validator, model, column)
17
17
  end
18
18
  end
19
19
  end.compact
@@ -1,3 +1,3 @@
1
1
  module DatabaseConsistency
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_consistency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin