Skip to content

Commit c726d2f

Browse files
bghalami-rcevolve75
authored andcommitted
Updated guard clause to include subtypes
1 parent df26673 commit c726d2f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/tree/utils/hash_converter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def from_hash(hash)
106106

107107
root, children = hash.first
108108

109-
raise ArgumentError, 'Invalid child. Must be nil or hash.' unless [Hash, NilClass].include?(children.class)
109+
raise ArgumentError, 'Invalid child. Must be nil or hash.'\
110+
unless [Hash, NilClass].any? { |c| children.is_a? c }
110111

111112
node = new(*root)
112113
node.add_from_hash(children) unless children.nil?

0 commit comments

Comments
 (0)