Module: ActiveRecord::Acts::MuckFriendUser::ClassMethods

Defined in:
lib/active_record/acts/muck_friend_user.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_muck_friend_user(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_record/acts/muck_friend_user.rb', line 11

def acts_as_muck_friend_user(options = {})

  has_many :friendships, :class_name  => "Friend", :foreign_key => 'inviter_id', :conditions => "status = #{MuckFriends::FRIENDING}", :dependent => :destroy
  has_many :follower_friends, :class_name => "Friend", :foreign_key => "invited_id", :conditions => "status = #{MuckFriends::FOLLOWING}", :dependent => :destroy
  has_many :following_friends, :class_name => "Friend", :foreign_key => "inviter_id", :conditions => "status = #{MuckFriends::FOLLOWING}", :dependent => :destroy
  has_many :blocked_friends, :class_name => "Friend", :foreign_key => "invited_id", :conditions => "status = #{MuckFriends::BLOCKED}", :dependent => :destroy

  has_many :friends,   :through => :friendships, :source => :invited
  has_many :followers, :through => :follower_friends, :source => :inviter
  has_many :followings, :through => :following_friends, :source => :invited
  has_many :blocked_users, :through => :blocked_friends, :source => :inviter
  
  has_many :initiated_by_me, :class_name => "Friend", :foreign_key => "inviter_id"
  has_many :not_initiated_by_me, :class_name => "Friend", :foreign_key => "invited_id"

  has_many :friendships_initiated_by_me, :through => :initiated_by_me, :source => :invited
  has_many :friendships_not_initiated_by_me, :through => :not_initiated_by_me, :source => :inviter
            
  has_many :occurances_as_friend, :class_name => "Friend", :foreign_key => "invited_id"

  include ActiveRecord::Acts::MuckFriendUser::InstanceMethods
  extend ActiveRecord::Acts::MuckFriendUser::SingletonMethods
  
end