Skip to content

Commit

Permalink
Updated guard clause to include subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
bghalami-rc authored and evolve75 committed Dec 20, 2024
1 parent df26673 commit c726d2f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/tree/utils/hash_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit c726d2f

Please sign in to comment.