Skip to content

Commit

Permalink
Rename not_null_latlng to with_latlng for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
jensb committed Nov 7, 2015
1 parent a9dcacc commit 37287c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/geokit-rails/acts_as_mappable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def adapter
def within(distance, options = {})
options[:within] = distance
#geo_scope(options)
not_null_latlng.where(distance_conditions(options))
with_latlng.where(distance_conditions(options))
end
alias inside within

Expand Down Expand Up @@ -140,10 +140,10 @@ def by_distance(options = {})
bounds = extract_bounds_from_options(options)
distance_column_name = distance_sql(origin, units, formula)
#geo_scope(options).order("#{distance_column_name} asc")
not_null_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")
with_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")
end

def not_null_latlng
def with_latlng
where("#{qualified_lat_column_name} IS NOT NULL AND #{qualified_lng_column_name} IS NOT NULL")
end

Expand Down
2 changes: 1 addition & 1 deletion test/acts_as_mappable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def test_find_with_through_with_hash
end

def test_sort_by_distance_from
locations = Location.not_null_latlng.all
locations = Location.with_latlng.all
unsorted = [locations(:a), locations(:b), locations(:c), locations(:d), locations(:e), locations(:f)]
sorted = [locations(:a), locations(:b), locations(:c), locations(:f), locations(:d), locations(:e)]
assert_equal sorted, locations.sort_by{|l| l.distance_to(locations(:a))}
Expand Down

0 comments on commit 37287c2

Please sign in to comment.