Sha256: 09fc0dc5b27bb9f22621b13a69649fb58f7b6d2cf95f5d84d1f930cf47e75bf6
Contents?: true
Size: 739 Bytes
Versions: 37
Compression:
Stored size: 739 Bytes
Contents
# # Example of extending a class when you need to synthesize an attribute. # # Adds Highrise::Person.{phone,fax,email} to the Person class inside your # module # module MyModule include Highrise 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 end
Version data entries
37 entries across 37 versions & 5 rubygems