Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created January 21, 2009 20:04
Show Gist options
  • Save brandon-beacher/50158 to your computer and use it in GitHub Desktop.
Save brandon-beacher/50158 to your computer and use it in GitHub Desktop.
# each
def self.lookup_primary_email(person_id)
emails_for_person = emails[person_id] || {}
emails_for_person.values.flatten.each do |email|
return email if email["primary"] == "1"
end
nil
end
# find
def self.lookup_primary_email(person_id)
emails_for_person = emails[person_id] || {}
emails_for_person.values.flatten.find { |email| email["primary"] == "1" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment