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 +4 -4
- data/lib/destination_errors.rb +15 -5
- data/lib/destination_errors/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3a5e8c45326abaec74d12735ed07c34fcb6967
|
4
|
+
data.tar.gz: 8d1a0884a7e647e46cae1b7f2e6961ce9512f299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fed81c47120851263221c1b7e788a68eab6f408998d136bf1462fd2547c56450963274cda4e8a3a70e2c7e9e4984a25a68480eeeb1e4c83ca8aa4f0c34b70ac
|
7
|
+
data.tar.gz: b669a0e57adae8765dea6cebfe327ff7814640c46b666148ed34a406b9598d11ce38b395ffd1fe4271f663792097858c87a460b9eb6c987639747aeb6eaba849
|
data/lib/destination_errors.rb
CHANGED
@@ -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,
|
122
|
-
move_error_to_destination(key,
|
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,
|
149
|
+
def move_error_to_destination(key, message_array)
|
150
150
|
if error_destination.respond_to?(key)
|
151
|
-
|
151
|
+
add_uniquely(key, message_array)
|
152
|
+
elsif key == :base
|
153
|
+
add_uniquely(:base, message_array)
|
152
154
|
else
|
153
|
-
|
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
|
|