Created
April 30, 2009 19:08
-
-
Save kmayer/104622 to your computer and use it in GitHub Desktop.
Sample how to extend Highrise::Person
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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