From e9ca1a9a572947ff1bee951e6820e5a7aaf5422a Mon Sep 17 00:00:00 2001 From: Ben Ghalami Date: Tue, 16 Apr 2024 14:59:39 -0600 Subject: [PATCH] Updated guard clause to include subtypes --- lib/tree/utils/hash_converter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tree/utils/hash_converter.rb b/lib/tree/utils/hash_converter.rb index f46d578..66c45ef 100644 --- a/lib/tree/utils/hash_converter.rb +++ b/lib/tree/utils/hash_converter.rb @@ -106,7 +106,8 @@ def from_hash(hash) root, children = hash.first - raise ArgumentError, 'Invalid child. Must be nil or hash.' unless [Hash, NilClass].include?(children.class) + raise ArgumentError, 'Invalid child. Must be nil or hash.'\ + unless [Hash, NilClass].any? { |c| children.is_a? c } node = new(*root) node.add_from_hash(children) unless children.nil?