Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Created October 29, 2015 20:26
Show Gist options
  • Select an option

  • Save nicholasjhenry/ccd6420b3cc19e4d9b09 to your computer and use it in GitHub Desktop.

Select an option

Save nicholasjhenry/ccd6420b3cc19e4d9b09 to your computer and use it in GitHub Desktop.
Overcoming Our Obsession with Stringly-Typed Ruby
class Address < ActiveRecord::Base
serialize :zip_code, ZipCode
end
class ZipCode
def self.load(raw_string)
self.new(raw_string)
end
def self.dump(zip_code)
zip_code.to_str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment