Skip to content

Commit

Permalink
Refactor composed_of into AddressUtilities. [#41]
Browse files Browse the repository at this point in the history
  • Loading branch information
marnen committed Oct 20, 2009
1 parent 8f77957 commit f82d0ee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion app/models/event.rb
Expand Up @@ -6,7 +6,6 @@ class Event < ActiveRecord::Base
belongs_to :calendar
has_many :commitments
has_many :users, :through => :commitments
composed_of :address, :mapping => %w(street street2 city state_id zip coords).collect{|x| [x, x.gsub(/_id$/, '')]}
# validates_presence_of :city
validates_presence_of :calendar_id
validates_presence_of :name
Expand Down
1 change: 0 additions & 1 deletion app/models/user.rb
Expand Up @@ -13,7 +13,6 @@ class User < ActiveRecord::Base
has_many :permissions
has_many :calendars, :through => :permissions
# validates_presence_of :permissions
composed_of :address, :mapping => %w(street street2 city state_id zip coords).collect{|x| [x, x.gsub(/_id$/, '')]}

validates_presence_of :email
validates_presence_of :password, :if => :password_required?
Expand Down
4 changes: 4 additions & 0 deletions lib/address_utilities.rb
@@ -1,4 +1,8 @@
module AddressUtilities
def self.included(klass)
klass.composed_of :address, :mapping => %w(street street2 city state_id zip coords).collect{|x| [x, x.gsub(/_id$/, '')]}
end

# Nil-safe country accessor.
def country
address.country
Expand Down

0 comments on commit f82d0ee

Please sign in to comment.