Skip to content

Commit

Permalink
Use a guard clause instead of wrapping the code inside a conditional …
Browse files Browse the repository at this point in the history
…expression
  • Loading branch information
sferik committed Dec 6, 2016
1 parent 5ca8fe0 commit 534f558
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/multi_xml/parsers/rexml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ def parse_error
# XML Document IO to parse
def parse(xml)
doc = REXML::Document.new(xml)
if doc.root
merge_element!({}, doc.root)
else
raise(REXML::ParseException.new("The document #{doc.to_s.inspect} does not have a valid root"))
end
raise(REXML::ParseException.new("The document #{doc.to_s.inspect} does not have a valid root")) unless doc.root
merge_element!({}, doc.root)
end

private
Expand Down

0 comments on commit 534f558

Please sign in to comment.