validated_object 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/lib/validated_object/version.rb +1 -1
- data/lib/validated_object.rb +7 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66bdc1ee048b6518b260908a2a48e8c4676c4350f99641a0da1c041fdc82a530
|
4
|
+
data.tar.gz: 27e9c03469ee86a4875fc9b99d8796055f12e48f7c627bbf410c7b43468c6022
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667688231472cb2d893ac1235be71c97111831f8f8510164c5152e4d37d4bd99b994c4cb189a36f1feb4af5786d0200b14e74ba27e69b7be3e1929795419d2db
|
7
|
+
data.tar.gz: ed1589b44cf7c83d7424ce46b5b09cb1990331aee38bee239232ed2e71b49b32a0c65e2a3fc4ad909c44cd2df1e0b81ee9e65b3191f35621ec50e1be2b499f30
|
data/.travis.yml
CHANGED
data/lib/validated_object.rb
CHANGED
@@ -63,18 +63,18 @@ module ValidatedObject
|
|
63
63
|
#
|
64
64
|
# @raise [ArgumentError] if the object is not valid at the
|
65
65
|
# end of initialization or `attributes` is not a Hash.
|
66
|
-
sig { params(attributes: SymbolHash).
|
66
|
+
sig { params(attributes: SymbolHash).void }
|
67
67
|
def initialize(attributes = EMPTY_HASH)
|
68
68
|
set_instance_variables from_hash: attributes
|
69
69
|
check_validations!
|
70
|
-
|
70
|
+
nil
|
71
71
|
end
|
72
72
|
|
73
73
|
# Run any validations and raise an error if invalid.
|
74
74
|
#
|
75
75
|
# @raise [ArgumentError] if any validations fail.
|
76
76
|
# @return [ValidatedObject::Base] the receiver
|
77
|
-
sig {returns(ValidatedObject::Base)}
|
77
|
+
sig { returns(ValidatedObject::Base) }
|
78
78
|
def check_validations!
|
79
79
|
raise ArgumentError, errors.full_messages.join('; ') if invalid?
|
80
80
|
|
@@ -118,17 +118,17 @@ module ValidatedObject
|
|
118
118
|
|
119
119
|
private
|
120
120
|
|
121
|
-
sig {params(expected_class: T.untyped, value: T.untyped).returns(T.untyped)}
|
121
|
+
sig { params(expected_class: T.untyped, value: T.untyped).returns(T.untyped) }
|
122
122
|
def pseudo_boolean?(expected_class, value)
|
123
123
|
expected_class == Boolean && boolean?(value)
|
124
124
|
end
|
125
125
|
|
126
|
-
sig {params(expected_class: T.untyped, value: T.untyped).returns(T.untyped)}
|
126
|
+
sig { params(expected_class: T.untyped, value: T.untyped).returns(T.untyped) }
|
127
127
|
def expected_class?(expected_class, value)
|
128
128
|
value.is_a?(expected_class)
|
129
129
|
end
|
130
130
|
|
131
|
-
sig {params(value: T.untyped).returns(T.untyped)}
|
131
|
+
sig { params(value: T.untyped).returns(T.untyped) }
|
132
132
|
def boolean?(value)
|
133
133
|
value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
134
134
|
end
|
@@ -150,7 +150,7 @@ module ValidatedObject
|
|
150
150
|
|
151
151
|
private
|
152
152
|
|
153
|
-
sig {params(from_hash: SymbolHash).void}
|
153
|
+
sig { params(from_hash: SymbolHash).void }
|
154
154
|
def set_instance_variables(from_hash:)
|
155
155
|
from_hash.each do |variable_name, variable_value|
|
156
156
|
# Test for the attribute reader
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validated_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.4.6
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: Self-validating plain Ruby objects.
|