Skip to content

Instantly share code, notes, and snippets.

@kmayer
Created April 30, 2009 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmayer/104622 to your computer and use it in GitHub Desktop.
Save kmayer/104622 to your computer and use it in GitHub Desktop.
Sample how to extend Highrise::Person
Highrise::Person.class_eval do
class << self
def lookup(id, list, item, location)
module_eval <<-EOT
def #{id}
contact_data.#{list}.each do |i|
return i.#{item}.strip if i.location == "#{location}"
end
''
end
EOT
end
private :lookup
end
lookup(:phone, 'phone_numbers', 'number', 'Work')
lookup(:fax, 'phone_numbers', 'number', 'Fax')
lookup(:email, 'email_addresses', 'address', 'Work')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment