Module: ZipMeta::Util

Defined in:
lib/zip_meta/util.rb

Overview

Contains implementation of the “zip_meta” method, which queries the zip_meta table for a record corresponding to the zipcode passed in.

Instance Method Summary collapse

Instance Method Details

#zip_meta(zipcode) ⇒ Object

Implementation of the “zip_meta” method, which queries the zip_meta table for a record corresponding to the zipcode passed in.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/zip_meta/util.rb', line 9

def zip_meta(zipcode)
  connection = ::ActiveRecord::Base.connection
  result_set = connection.select_all("SELECT * FROM zip_meta WHERE zip=#{connection.quote(zipcode)}")
  if result_set.count == 0 
    nil
  else
    zip_meta_item = result_set[0]
    zip_meta_item.delete("id")
    zip_meta_item.symbolize_keys!
    zip_meta_item
  end
end