errorio 0.1.3 → 0.1.4
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 +4 -4
- data/lib/errorio/errors.rb +21 -2
- data/lib/errorio/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8116084f9ceec078a68f59395c02c9aa189c59c76f1fc352b95e58101017fea
|
4
|
+
data.tar.gz: 826674e752fc0e05368490bde9c5111ea4f3530c64478ac0f017ab000cfae360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5158836c975f2a117aa507cec2d20cbae54f693162c80c833dfe52203ab79251dc14491dffeeb78ec55c26a5fde2cb4c9f30d3163ca459cd93dab88a2583d27f
|
7
|
+
data.tar.gz: d65d9b1abd8cfd6173562fa706573c569abaa952360898e63ab382aa7ba682e0bb59ba65a1a638a087b10c9783f1e5eca395ee4a07850d95ec8b2b88ea35cc9b
|
data/lib/errorio/errors.rb
CHANGED
@@ -12,14 +12,33 @@ module Errorio
|
|
12
12
|
@errors = []
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# Adds a new error to errors collection
|
16
|
+
#
|
17
|
+
# @param [Symbol] attribute
|
18
|
+
# @param [Symbol] type
|
19
|
+
# @param [Hash] options
|
20
|
+
def add(attribute, type = :invalid, options = {})
|
21
|
+
error = Error.new(@base, attribute, type, options)
|
17
22
|
|
18
23
|
@errors.append(error)
|
19
24
|
|
20
25
|
error
|
21
26
|
end
|
22
27
|
|
28
|
+
# Copy errors from another errors object
|
29
|
+
#
|
30
|
+
# @param [Errorio::Errors,ActiveModel::Errors] other
|
31
|
+
def copy(other)
|
32
|
+
other.each do |err|
|
33
|
+
options = err.options
|
34
|
+
|
35
|
+
# ActiveModel::Error object has own way to generate message attribute,
|
36
|
+
options[:message] = err.message if err.is_a?(ActiveModel::Error)
|
37
|
+
|
38
|
+
add err.attribute, err.type, options
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
23
42
|
# Returns all error attribute names
|
24
43
|
#
|
25
44
|
# person.errors.messages # => {:name=>["cannot be nil", "must be specified"]}
|
data/lib/errorio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: errorio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadym Lukavyi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|