user1310656 user1310656 - 3 months ago 5
Ruby Question

ruby long line wrap up

How to wrap up this long line so not break the maximum 80 length rule? At where to break the line?

raise XxxxxxxxxxxxxxxxxxxxxxError unless [HTTP_STATUS_CODE[:OK], HTTP_STATUS_CODE[:xxxxxxxxxxxxxx]].include? http_status_code


You can break unless into a multi-line block. I'll suggest that you extract the array out into a variable perhaps?

accepted_codes = [HTTP_STATUS_CODE[:OK], HTTP_STATUS_CODE[:created]]
unless accepted codes.include? http_status_code
  raise StandardError