Skip to content
Browse files

ZipCodes#by_code_and_name and #by_name both also use short names too …

…now.
  • Loading branch information...
1 parent 81597da commit 01d9017057adb8db1b706cfc5a4ef03fa4056655 @apeiros committed
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/swissmatch/zipcodes.rb
View
4 lib/swissmatch/zipcodes.rb
@@ -218,7 +218,7 @@ def by_code_and_add_on(code, add_on)
# The SwissMatch::ZipCode with the given 4 digit code and name in any language.
def by_code_and_name(code, name)
@by_code_and_name ||= Hash[@zip_codes.flat_map { |c|
- c.names.map { |name| [[c.code, name], c] }
+ (c.names + c.names_short).map(&:to_s).uniq.map { |name| [[c.code, name], c] }
}]
@by_code_and_name[[code,name]]
end
@@ -227,7 +227,7 @@ def by_code_and_name(code, name)
# A SwissMatch::ZipCodes collection with all SwissMatch::ZipCode objects having the given name.
def by_name(name)
@by_name ||= @zip_codes.each_with_object({}) { |zip_code, hash|
- zip_code.names.map(&:to_s).uniq.each do |name|
+ (zip_code.names + zip_code.names_short).map(&:to_s).uniq.each do |name|
hash[name] ||= []
hash[name] << zip_code
end

0 comments on commit 01d9017

Please sign in to comment.
Something went wrong with that request. Please try again.