destination_errors 0.0.4 → 0.0.5

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: 2b0d1e913a5dd6b4ff6879838460b50edea24bb7
4
- data.tar.gz: cba1186d7b96cefa43087297341d7e2a9928166a
3
+ metadata.gz: 1f3a5e8c45326abaec74d12735ed07c34fcb6967
4
+ data.tar.gz: 8d1a0884a7e647e46cae1b7f2e6961ce9512f299
5
5
  SHA512:
6
- metadata.gz: 199dc1f6c651a7f302a45b13bee6c9fd73f8b5ab69756b85baa7e846b8be369614b356d4e95ed56d0328b04d98c606341e6fbe85fe3b060aead713ffdec49654
7
- data.tar.gz: e5f9fe80bfab3483c03604be00b8be04ee5e321448a534a3d6f776bfa9456374d2f7510ebc9bb3f13ec1ca1cf0ec38fbfb7ebbfcfc2081ce8af78d97656d0749
6
+ metadata.gz: 5fed81c47120851263221c1b7e788a68eab6f408998d136bf1462fd2547c56450963274cda4e8a3a70e2c7e9e4984a25a68480eeeb1e4c83ca8aa4f0c34b70ac
7
+ data.tar.gz: b669a0e57adae8765dea6cebfe327ff7814640c46b666148ed34a406b9598d11ce38b395ffd1fe4271f663792097858c87a460b9eb6c987639747aeb6eaba849
@@ -118,8 +118,8 @@ module DestinationErrors
118
118
  surface.nil? ?
119
119
  errors.messages :
120
120
  self.send(surface).errors.messages
121
- ).each do |key, message|
122
- move_error_to_destination(key, message)
121
+ ).each do |key, message_array|
122
+ move_error_to_destination(key, message_array)
123
123
  end
124
124
  end
125
125
  end
@@ -146,11 +146,21 @@ module DestinationErrors
146
146
  surface_errors_on.nil? || !self.send(surface_errors_on)
147
147
  end
148
148
 
149
- def move_error_to_destination(key, message)
149
+ def move_error_to_destination(key, message_array)
150
150
  if error_destination.respond_to?(key)
151
- error_destination.errors.add(key, *message)
151
+ add_uniquely(key, message_array)
152
+ elsif key == :base
153
+ add_uniquely(:base, message_array)
152
154
  else
153
- error_destination.errors.add(:base, *message)
155
+ add_uniquely(:base, message_array.map {|message| "#{key} #{message}"})
156
+ end
157
+ end
158
+
159
+ def add_uniquely(key, message_array)
160
+ message_array.each do |message|
161
+ unless error_destination.errors[key].include?(message)
162
+ error_destination.errors.add(key, message)
163
+ end
154
164
  end
155
165
  end
156
166
 
@@ -1,3 +1,3 @@
1
1
  module DestinationErrors
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: destination_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling