summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/validators.rb
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-05-20 17:52:35 +0200
committerGeremia Taglialatela <[email protected]>2023-05-20 17:52:35 +0200
commit611b57cdd44f3f5e91394c699ad98b7c05330a2e (patch)
tree3ac799c34fdc418ae31145feb1edf9d363b1d69a /lib/axlsx/util/validators.rb
parent6a4b82def2e94b4811c38c37e606d426710d1e6c (diff)
downloadcaxlsx-611b57cdd44f3f5e91394c699ad98b7c05330a2e.tar.gz
caxlsx-611b57cdd44f3f5e91394c699ad98b7c05330a2e.zip
Remove minor safe offenses
- Style/RaiseArgs - Style/RedundantCondition - Style/RedundantReturn - Style/SelfAssignment - Style/SoleNestedConditional
Diffstat (limited to 'lib/axlsx/util/validators.rb')
-rw-r--r--lib/axlsx/util/validators.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb
index e9cf13b6..72e3f2d8 100644
--- a/lib/axlsx/util/validators.rb
+++ b/lib/axlsx/util/validators.rb
@@ -55,9 +55,10 @@ module Axlsx
# @return [Boolean] true if validation succeeds.
# @see validate_boolean
def self.validate(name, types, v, other = false)
- if other.is_a?(Proc)
- raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) unless other.call(v)
+ if other.is_a?(Proc) && !other.call(v)
+ raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect])
end
+
v_class = v.is_a?(Class) ? v : v.class
Array(types).each do |t|
return if v_class <= t