pluginaweek / has_phone_numbers

Demonstrates a reference implementation for handling phone numbers

This URL has Read+Write access

obrie (author)
Tue Jun 09 20:32:46 -0700 2009
commit  57bcf94d67fb2e7d1481f4641cf0161b806229c1
tree    b80762fd8e17ee49694cc715c9f73ce9d4856413
parent  4a02eadd91a8438f8a8b551064573e7ceb4d5e17
has_phone_numbers / lib / has_phone_numbers.rb
100644 15 lines (13 sloc) 0.398 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Adds a generic implementation for dealing with phone numbers
module HasPhoneNumbers
  module MacroMethods
    # Creates the following association:
    # * +phone_number+ - All phone numbers associated with the current record.
    def has_phone_numbers
      has_many :phone_numbers, :as => :phoneable
    end
  end
end
 
ActiveRecord::Base.class_eval do
  extend HasPhoneNumbers::MacroMethods
end