Im wondering how could I refactor this code. It may look a little reiterative and probably there's a shorter method to accomplish the same.
def self.location(distance=100,location)
if distance.is_a? Integer
if distance.between?(1,5000)
distance = distance
elsif distance < 1
distance = 1
elsif distance > 5000
distance = 5000
end
else
distance = 100
end
if location
within(distance, :origin => location)
else
find(:all)
end
end