is_hash_valid 1.1.1 → 1.1.2

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: b8bbbdef9cccd7f6cd83e79af707b7c3b8ec73c5
4
- data.tar.gz: b117e808c72081f7750c337b7883324f81491051
3
+ metadata.gz: db9e84d89a56462bce6787e59e468aaba38f31e8
4
+ data.tar.gz: ec50f9d13ea30c77b3a50eb10870239fe46dad42
5
5
  SHA512:
6
- metadata.gz: 822ecd1710f9bbb776f8835aee77aa5558563141bfa88b960ceccf90de8aa2f9a7b3eb21e8849b6247279b11775ca17a5e87522f98bfe6f56b30119f0a63d240
7
- data.tar.gz: 728d64354fb8f0b97b3bd71a5da012d4268c5b567ceb0af204d83a3e1515f9c1326cabca0aa5054ff7b55f1bc096e526323989a8e30ad82b282cf12fc2964ae4
6
+ metadata.gz: 2bc3130787582fdf3d2dd6956899e92e8c5aa04b1d4891084ac7e88b9dbd4d4325d2f0d2f137ff3c7301278192ed542fd8558f2573980e1fe71bd5a74aef2734
7
+ data.tar.gz: 553dcb0f33fa905171c8139648ea86d5e8db41e873691c59bab764ed2a0d483187644283ab9ab1ee3ce7336db5254872a6da5df73a5c6895d4ff75f7f3dce5f8
@@ -4,9 +4,9 @@ module IsHashValid
4
4
  class Validator
5
5
  include IsHashValid::Validators
6
6
 
7
- def initialize(hash, validators)
7
+ def initialize(hash, validators_for_feilds)
8
8
  @hash = hash
9
- @validators = validators
9
+ @validators_for_feilds = validators_for_feilds
10
10
  @errors = { }
11
11
  validate
12
12
  end
@@ -20,11 +20,14 @@ module IsHashValid
20
20
  end
21
21
 
22
22
  def validate
23
- @validators.each do |field, validators|
23
+ @validators_for_feilds.each do |field, validators|
24
24
  validators.each do |validator, message|
25
- if !self.send(validator.to_sym, @hash[field.to_sym])
26
- @errors[field] = [] unless @errors.has_key? field
27
- @errors[field].push(message)
25
+ unless self.send(validator.to_sym, @hash[field.to_sym])
26
+ if @errors.has_key? field
27
+ @errors[field].push(message)
28
+ else
29
+ @errors[field] = [message]
30
+ end
28
31
  end
29
32
  end
30
33
  end
@@ -1,3 +1,3 @@
1
1
  module IsHashValid
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -9,8 +9,8 @@ describe IsHashValid::Validator do
9
9
  expect(subject.instance_variable_get(:@hash)).to eq({})
10
10
  end
11
11
 
12
- it "expects @validators to be set" do
13
- expect(subject.instance_variable_get(:@validators)).to eq({})
12
+ it "expects @validators_for_feilds to be set" do
13
+ expect(subject.instance_variable_get(:@validators_for_feilds)).to eq({})
14
14
  end
15
15
  end
16
16
 
@@ -2,5 +2,5 @@ require 'spec_helper'
2
2
  require './lib/is_hash_valid/version.rb'
3
3
 
4
4
  describe "Version" do
5
- it { expect(IsHashValid::VERSION).to eq("1.1.1") }
5
+ it { expect(IsHashValid::VERSION).to eq("1.1.2") }
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_hash_valid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Janecke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler