I'm refactoring an old gateway and came across the following method:
def apply_limit_and_offset(options)
limit = options[:limit]
offset = options[:offset]
@result = if offset
@result.drop offset
else
@result
end
@result = if limit
@result.first limit
else
@result
end
@result
end
@result
is an Array
of objects.
Any suggestions on how to refactor this? It works just fine, but multiple if
statements make me feel gross.